db

package
v0.0.0-...-51a7f25 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package db handles the DB connections and ORM. Should be initialized with "Init" function before using.

Index

Constants

View Source
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

func BulkInsert(entities []model.Entity) error

BulkInsert function does a bulk insert of a set of entities and returns any error encountered.

func CloseDBCon

func CloseDBCon()

CloseDBCon function closes the open DB connections.

func CreateTable

func CreateTable(e model.Entity)

CreateTable creates a table for the given model only if table already not exists. Program will be closed if any error encountered.

func Delete

func Delete(e model.Entity) error

Delete deletes the given ServiceInstance from the Database. Returns any error encountered.

func Init

func Init(conf *config.DB)

Init initialize database parameters and open a DB connection.

func Retrieve

func Retrieve(e model.Entity) (bool, error)

Retrieve function initialize the given ServiceInstance from the database if exists. Returns true if the instance exists and any error encountered.

func RetrieveList

func RetrieveList(e model.Entity, r interface{}) (bool, error)

func RetrieveListByQuery

func RetrieveListByQuery(e model.Entity, query string, r interface{}) (bool, error)

func Store

func Store(e model.Entity) error

Store saves the given ServiceInstance in the Database. Returns any error encountered.

func Update

func Update(e model.Entity) error

Update updates the given ServiceInstance in the Database. Returns any error encountered.

Types

This section is empty.

Jump to

Keyboard shortcuts

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