Documentation
¶
Overview ¶
Package db handles the DB connections and ORM. Should be initialized with "Init" function before using.
Index ¶
- Constants
- func AddForeignKey(e model.Entity, field string, dest string, onDelete string, onUpdate string) error
- func BulkInsert(entities []model.Entity) error
- func CloseDBCon()
- func CreateTable(e model.Entity)
- func Delete(e model.Entity) error
- func Init(conf *config.DB)
- func Retrieve(e model.Entity) (bool, error)
- func RetrieveList(e model.Entity, r interface{}) (bool, error)
- func RetrieveListByQuery(e model.Entity, query string, r interface{}) (bool, error)
- func Store(e model.Entity) error
- func Update(e model.Entity) error
Constants ¶
const ( MySQL = "mysql" ErrMsgUnableToOpenDBCon = "unable to open a DB connect" )
Variables ¶
This section is empty.
Functions ¶
func AddForeignKey ¶
func AddForeignKey(e model.Entity, field string, dest string, onDelete string, onUpdate string) error
AddForeignKey adds a Foreign Key and returns any error encountered. Ex: db.AddForeignKey(&User{}).AddForeignKey("city_id", "cities(id)", "RESTRICT", "RESTRICT").
func BulkInsert ¶
BulkInsert function does a bulk insert of a set of entities and returns any error encountered.
func CreateTable ¶
CreateTable creates a table for the given model only if table already not exists. Program will be closed if any error encountered.
func Delete ¶
Delete deletes the given ServiceInstance from the Database. Returns any error encountered.
func Retrieve ¶
Retrieve function initialize the given ServiceInstance from the database if exists. Returns true if the instance exists and any error encountered.
func RetrieveListByQuery ¶
Types ¶
This section is empty.