Documentation
¶
Index ¶
- type Configurator
- type Model
- func (m *Model) CloseClient()
- func (m *Model) Create(data base.Scheme) error
- func (m *Model) Delete(data base.Scheme) error
- func (m *Model) EnsureIndex(indices ...base.Index)
- func (m *Model) Find(id interface{}) (base.Scheme, error)
- func (m *Model) Initiate(scheme base.Scheme, config base.DBConfig, configurators ...Configurator)
- func (m *Model) PrepareClient()
- func (m *Model) Update(data base.Scheme) error
- func (m *Model) Where(query ...base.Condition) base.QueryBuilder
- type MongoScheme
- type Scheme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configurator ¶
type Configurator func(*Model)
Configurator is a function for configuring Model attributes. Usually it is used for adding indices or configure table name, or even configuring drivers with custom drivers
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is an object that responsible for interacting
func (*Model) CloseClient ¶
func (m *Model) CloseClient()
CloseClient close and destroy client connection
func (*Model) Create ¶
Create inserts the given filled scheme into model table/collection and return inserted record/document or error if there was any fault in data insertion.
func (*Model) Delete ¶
Delete find a record/document that match with data ID and remove it from related table/collection. It will return error if anything went wrong
func (*Model) EnsureIndex ¶
EnsureIndex checks for table/collection existence in database, if not found tries to create it. Then it ensures that given indices are exists on table/collection.
func (*Model) Find ¶
Find search for a record/document in model table/collection match with given ID
func (*Model) PrepareClient ¶
func (m *Model) PrepareClient()
PrepareClient Prepare client for further actions
type MongoScheme ¶ added in v0.1.4
type MongoScheme struct{}
MongoScheme is the base scheme, same as Scheme, for mongo db schemes
func (MongoScheme) GetKeyName ¶ added in v0.1.4
func (s MongoScheme) GetKeyName() string
GetKeyName return the name of primary key field name