Documentation ¶
Index ¶
- type Adapter
- func (adapter *Adapter) Collection(collectionName string) *models.Collection
- func (adapter *Adapter) Collections() []*models.Collection
- func (adapter *Adapter) NewQuery(collection *models.Collection) models.Queryable
- func (adapter *Adapter) RegisterCollection(collectionName string, collection *models.Collection)
- type Base
- func (base *Base) Destroy() error
- func (base *Base) GetCollectionName() string
- func (base *Base) GetHooksHandler() *models.HooksHandler
- func (base *Base) GetID() string
- func (base *Base) InitializeBase(context *models.Context)
- func (base *Base) IsNewRecord() bool
- func (base *Base) Reload() error
- func (base *Base) Save() error
- func (base *Base) Store()
- func (base *Base) StoreInList(list *models.List)
- type Query
- func (query *Query) Count() *models.CountResult
- func (query *Query) DestroyAll() error
- func (query *Query) Each(handler func(models.Modellable, error) bool) error
- func (query *Query) Find(id string) *models.SingleResult
- func (query *Query) First() *models.SingleResult
- func (query *Query) FirstOrCreate(attributes helpers.H) *models.SingleResult
- func (query *Query) ToList() *models.ListResults
- func (query *Query) Where(filters helpers.H) models.Queryable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is adapter for mongo
func MakeAdapter ¶
MakeAdapter used to instantiate mongorecord's adapter
func (*Adapter) Collection ¶
func (adapter *Adapter) Collection(collectionName string) *models.Collection
Collection used to retrieve registered collection
func (*Adapter) Collections ¶
func (adapter *Adapter) Collections() []*models.Collection
Collections used to retrieve registered collections
func (*Adapter) NewQuery ¶
func (adapter *Adapter) NewQuery(collection *models.Collection) models.Queryable
NewQuery used to generate query
func (*Adapter) RegisterCollection ¶
func (adapter *Adapter) RegisterCollection(collectionName string, collection *models.Collection)
RegisterCollection used to register collection with adapter
type Base ¶
type Base struct { ID primitive.ObjectID `bson:"_id" json:"id"` CreatedAt time.Time `bson:"created_at" json:"createdAt"` UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"` // contains filtered or unexported fields }
Base used to represent base classes for all models
func (*Base) GetCollectionName ¶
GetCollectionName used to retrieve collection's name
func (*Base) GetHooksHandler ¶
func (base *Base) GetHooksHandler() *models.HooksHandler
GetHooksHandler used to retrieve hooks handler
func (*Base) InitializeBase ¶
InitializeBase used for setting up base attributes for a mongo record
func (*Base) IsNewRecord ¶
IsNewRecord used to check if record is new unsaved record
func (*Base) StoreInList ¶
StoreInList used to add record to selected list
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a wrapper for querying mongo
func (*Query) Count ¶
func (query *Query) Count() *models.CountResult
Count used to count records in collection with matching criterion
func (*Query) DestroyAll ¶
DestroyAll used to destroy all records in collection with matching criterion
func (*Query) Find ¶
func (query *Query) Find(id string) *models.SingleResult
Find use to find record by id
func (*Query) First ¶
func (query *Query) First() *models.SingleResult
First used to return first record in collection with matching criterion
func (*Query) FirstOrCreate ¶
func (query *Query) FirstOrCreate(attributes helpers.H) *models.SingleResult
FirstOrCreate used to return first record in collection with matching criterion, create one and return if not found
func (*Query) ToList ¶
func (query *Query) ToList() *models.ListResults
ToList used to iterate record in collection with matching criterion