Documentation ¶
Index ¶
- Variables
- func ToDBName(name string) string
- type DBService
- type InstanceNotFoundError
- type ModelDescriptor
- type ModelRegistry
- type ModelRegistryImpl
- type Repository
- type SQLExpr
- type Service
- func (p *Service) Create(class string, data interface{}) error
- func (p *Service) Get(class string, id interface{}, ass string) (interface{}, error)
- func (p *Service) GetDB() *gorm.DB
- func (p *Service) List(class string, selectFields []string, where string, whereValues []interface{}, ...) (map[string]interface{}, error)
- func (p *Service) Remove(className string, id interface{}) (interface{}, error)
- func (p *Service) Update(className string, data interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var NowFunc = func() time.Time { return time.Now() }
NowFunc returns current time, this function is exported in order to be able to give the flexibility to the developer to customize it according to their needs, e.g:
gorm.NowFunc = func() time.Time { return time.Now().UTC() }
Functions ¶
Types ¶
type InstanceNotFoundError ¶
type InstanceNotFoundError struct {
// contains filtered or unexported fields
}
InstanceNotFoundError xxx
func (*InstanceNotFoundError) Error ¶
func (p *InstanceNotFoundError) Error() string
type ModelDescriptor ¶
type ModelDescriptor struct { Type interface{} New func() interface{} NewSlice func() interface{} }
ModelDescriptor db model descriptor
type ModelRegistry ¶
type ModelRegistry interface { Put(name string, model *ModelDescriptor) Get(name string) *ModelDescriptor Models() <-chan *ModelDescriptor }
ModelRegistry Register all orm models
type ModelRegistryImpl ¶
type ModelRegistryImpl struct {
// contains filtered or unexported fields
}
ModelRegistryImpl model registry impelement struct
func (*ModelRegistryImpl) Get ¶
func (p *ModelRegistryImpl) Get(name string) *ModelDescriptor
Get get db model by model struct name
func (*ModelRegistryImpl) Models ¶
func (p *ModelRegistryImpl) Models() <-chan *ModelDescriptor
Models models channels
func (*ModelRegistryImpl) Put ¶
func (p *ModelRegistryImpl) Put(name string, model *ModelDescriptor)
Put registry db model
type Repository ¶
type Repository interface { Get(class string, id interface{}, ass string) (interface{}, error) List(class string, selectFields []string, where string, whereValues []interface{}, order string, page int, pageSize int) (map[string]interface{}, error) Create(class string, data interface{}) error Remove(className string, id interface{}) (interface{}, error) Update(className string, data interface{}) error GetDB() *gorm.DB }
Repository manage all objects in db
type Service ¶
type Service struct { DB DBService `inject:"DB"` ModelRegistry ModelRegistry `inject:"DB"` }
Service orm service struct
func (*Service) List ¶
func (p *Service) List(class string, selectFields []string, where string, whereValues []interface{}, order string, page int, pageSize int) (map[string]interface{}, error)
List query db model list with where conditions
Click to show internal directories.
Click to hide internal directories.