Documentation ¶
Index ¶
- type Builder
- func (b *Builder) All() ([]base.Scheme, error)
- func (b *Builder) Count() (int, error)
- func (b *Builder) Delete() (int, error)
- func (b *Builder) First() (base.Scheme, error)
- func (b *Builder) Limit(n int) base.Builder
- func (b *Builder) OrderBy(sorts ...base.Sort) base.Builder
- func (b *Builder) Skip(n int) base.Builder
- func (b *Builder) Update(data base.Scheme) (int, error)
- 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) GetClient() base.Client
- func (m *Model) GetCollection() (base.MongoCollection, 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.Builder
- type MongoScheme
- type Scheme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶ added in v0.2.0
type Builder struct {
// contains filtered or unexported fields
}
Builder is a wrapper around QueryBuilder that convert RecordData object to model's related scheme.
func NewBuilder ¶ added in v0.2.0
func NewBuilder(builder base.QueryBuilder, model *Model) *Builder
NewBuilder instantiate Builder with given QueryBuilder
func (*Builder) All ¶ added in v0.2.0
All returns results that match with query conditions in RecordDataSet format. If the query conditions was empty it will return all records in specified destination table or error if anything went wrong.
func (*Builder) Count ¶ added in v0.2.0
Count execute a count command that will return the number records in specified destination table. If the query conditions was empty, it returns number of all records un destination table.
func (*Builder) Delete ¶ added in v0.2.0
Delete removes every records in destination table that match with condition query and returns number of affected rows and error if anything went wrong. It will removes all records inside destination table if no condition query was set.
func (*Builder) First ¶ added in v0.2.0
First fetch data of the first record that match with query conditions.
func (*Builder) Limit ¶ added in v0.2.0
Limit set the limit that determines how many results should be returned in the following fetch command.
func (*Builder) OrderBy ¶ added in v0.2.0
OrderBy set the order of returning result in following command
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) GetClient ¶ added in v0.2.5
GetClient returns database client. Note that client should be closed after use.
func (*Model) GetCollection ¶ added in v0.2.5
func (m *Model) GetCollection() (base.MongoCollection, error)
GetCollection returns collection object for mongo db.
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