db

package
v0.0.0-...-608c3ca Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close database connection

func Connect

func Connect(host string, port int, user, password, dbname string, sslmode bool) (*sql.DB, error)

Connect connects to the database

func DeleteStruct

func DeleteStruct(table string, conditions builder.Builder) error

DeleteStruct delete struct instance in the database table

func Exec

func Exec(statement builder.Builder) error

Exec prepare the statement and insert into the database

func InsertStruct

func InsertStruct(table string, model interface{}) (string, error)

InsertStruct insert struct values in the database table

func LoadStruct

func LoadStruct(table string, model interface{}, conditions builder.Builder) error

LoadStruct select struct values from the database table. model must be a pointer to a struct or an array.

func Query

func Query(statement builder.Builder) (*sql.Rows, error)

Query prepare the statement, executes and returns the Rows

func QueryStruct

func QueryStruct(statement builder.Builder, model interface{}) error

QueryStruct prepare and execute the statement and then populates the model model must be a pointer to a struct or an array.

func StructDeleteQuery

func StructDeleteQuery(table string, conditions builder.Builder) (string, []interface{}, error)

StructDeleteQuery generates the delete query based on the struct fields

func StructInsertQuery

func StructInsertQuery(table string, obj interface{}) (string, []interface{})

StructInsertQuery generates the insert query based on the struct fields

func StructMultipleInsertQuery

func StructMultipleInsertQuery(table string, obj interface{}) (string, []interface{})

StructMultipleInsertQuery generates the insert query based on the array of structs

func StructScan

func StructScan(rows *sql.Rows, obj interface{}) error

StructScan write rows data to struct array or struct

func StructSelectQuery

func StructSelectQuery(table string, obj interface{}, conditions builder.Builder) (string, []interface{}, error)

StructSelectQuery generates the select query based on the struct fields Object can be a poninter to an array or struct

func StructUpdateQuery

func StructUpdateQuery(table string, obj interface{}, updatableFields string, conditions builder.Builder) (string, []interface{}, error)

StructUpdateQuery generates the update query based on the struct fields

func UpdateStruct

func UpdateStruct(table string, model interface{}, conditions builder.Builder, fields ...string) error

UpdateStruct update struct values in the database table

Types

This section is empty.

Jump to

Keyboard shortcuts

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