pg

package
v0.0.0-...-8e695b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2021 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conn

func Conn() *sqlx.DB

Conn - Gives default connection

func Connect

func Connect(optStr string) (db *sqlx.DB, err error)

Connect - connects to DB based on connection string

func ConnectWithOpts

func ConnectWithOpts(opts *ConnOpts) (db *sqlx.DB, err error)

ConnectWithOpts - connect to postgresdb based on given options

func NamedConn

func NamedConn(name string) *sqlx.DB

NamedConn - gives connection to database associated with given name. If no connection exists with given name nil is returned. If name is empty default connection is returned

func NewDefaultApp

func NewDefaultApp(
	name string,
	appVersion teak.Version,
	apiVersion int,
	desc string) *teak.App

NewDefaultApp - creates a new app with MongoDB based storage providers

func NewStorage

func NewStorage() teak.DataStorage

NewStorage - creates a new mongodb based data storage implementation

func NewUserStorage

func NewUserStorage() teak.UserStorage

NewUserStorage - creates a new user storage based on postgres

func SetDefaultConn

func SetDefaultConn(db *sqlx.DB)

SetDefaultConn - sets the default postgres connection

func SetNamedConn

func SetNamedConn(name string, db *sqlx.DB)

SetNamedConn - register a postgres connection against name

Types

type ConnOpts

type ConnOpts struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	DBName   string `json:"dbName"`
}

ConnOpts - postgres connection options

func (*ConnOpts) String

func (c *ConnOpts) String() string

String - get usable connection string

type DBAttr

type DBAttr map[string]interface{}

DBAttr - used to store generic data in a JSONB column

func (*DBAttr) Scan

func (a *DBAttr) Scan(value interface{}) error

Scan - read JSON into attributes

func (DBAttr) Value

func (a DBAttr) Value() (driver.Value, error)

Value - convert attribute to JSON while storing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL