dao

package
v0.0.0-...-4518a5d Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDaoManager = NewManager()

DefaultDaoManager default dai manager. for default on app

OperatorCodeMap key = OperatorCode , value = string

Functions

func OpenTestMysqlDatabaseConnection

func OpenTestMysqlDatabaseConnection() (db *gorm.DB)

OpenTestMysqlDatabaseConnection open mysql database connection

func RegisterCoreModel

func RegisterCoreModel()

RegisterCoreModel register model on common-lib

Types

type GeneratorDefinition

type GeneratorDefinition struct {
	//Generator generator single instance
	Generator StructGeneratorFunction
	//SliceGenerator generator slice ( pointer)
	SliceGenerator StructSliceGeneratorFunction
}

GeneratorDefinition wrapper generator

type Manager

type Manager interface {
	//RegisterModel register model to manager
	RegisterModel(instanceGenerators ...GeneratorDefinition)
	//FindByID find data by id
	FindByID(modelName string, IDstring string, DB *gorm.DB, logEntry *logrus.Entry) (result interface{}, err error)
	//List query for list of data
	List(modelName string, q query.Q, pageSize int32, page int32, DB *gorm.DB, baseLogEntry *logrus.Entry) (listData interface{}, count int64, err error)

	//GetColumnName membaca nama column actual. dari catalog membaca nama actual column
	//syaratnya model sudah di register. kalau model belum di register ini akan throw error
	GetColumnName(modelName string, name string) (dbColumnName string, err error)

	//GenerateDaoWithWhere generate where. so reference is ready to use for query ( i.e. for count, list etc)
	GenerateDaoWithWhere(modelName string, q query.Q, DB *gorm.DB, baseLogEntry *logrus.Entry) (dbWithWhere *gorm.DB, err error)
	//SimpleManager generate simple dao manager
	SimpleManager(DB *gorm.DB, baseLogEntry *logrus.Entry) SimpleDaoManager
}

Manager dao manager interface

func GetDaoManager

func GetDaoManager() Manager

GetDaoManager get manager current

func NewManager

func NewManager() Manager

NewManager generate dao manager

type OperatorCode

type OperatorCode string

OperatorCode code for query operator. for parsing json param query

const (
	//OprEq code for eq( = )
	OprEq OperatorCode = "$eq"
	//OprGt code for gt( > )
	OprGt OperatorCode = "$gt"
	//OprGte code for gte( >= )
	OprGte OperatorCode = "$gte"
	//OprIn code for in
	OprIn OperatorCode = "$in"
	//OprIsNot code for is not
	OprIsNot OperatorCode = "$isNot"
	//OprIs  code for is
	OprIs OperatorCode = "$is"
	//OprLike  code for like
	OprLike OperatorCode = "$like"
	//OprNotLike parse parse operaator not like
	OprNotLike OperatorCode = "$notLike"
	//OprLt  code for <( less then )
	OprLt OperatorCode = "$lt"
	//OprLte  code for <=( less then equals)
	OprLte OperatorCode = "$lte"
	//OprNe  code for != ( not equals)
	OprNe OperatorCode = "$ne"
	//OprOr code for or
	OprOr OperatorCode = "$or"
)

func (OperatorCode) StartWith

func (p OperatorCode) StartWith(testedQuery string) (result bool)

StartWith check apah string start with code

type SimpleDaoManager

type SimpleDaoManager interface {

	//FindByID find data by id
	FindByID(modelName string, IDstring string) (result interface{}, err error)
	//GenerateDaoWithWhere generate where. so reference is ready to use for query ( i.e. for count, list etc)
	GenerateDaoWithWhere(modelName string, q query.Q) (dbWithWhere *gorm.DB, err error)
	//List query for list of data
	List(modelName string, q query.Q, pageSize int32, page int32) (listData interface{}, count int64, err error)
}

SimpleDaoManager dao manager with strip down param. db an log entry passes as member variable on struct

func NewSimpleManager

func NewSimpleManager(daoManager Manager, DB *gorm.DB, logEntry *logrus.Entry) SimpleDaoManager

NewSimpleManager generate new simple dao manager

type StructGeneratorFunction

type StructGeneratorFunction func() (instance interface{})

StructGeneratorFunction generator struct

type StructSliceGeneratorFunction

type StructSliceGeneratorFunction func() (instance interface{})

StructSliceGeneratorFunction generator slice for struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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