mongorecords

package
v1.0.82 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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

func MakeAdapter(uri string, databaseName string) (*Adapter, error)

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) Destroy

func (base *Base) Destroy() error

Destroy used to delete record from database

func (*Base) GetCollectionName

func (base *Base) GetCollectionName() string

GetCollectionName used to retrieve collection's name

func (*Base) GetHooksHandler

func (base *Base) GetHooksHandler() *models.HooksHandler

GetHooksHandler used to retrieve hooks handler

func (*Base) GetID

func (base *Base) GetID() string

GetID used to retrieve record's ID

func (*Base) InitializeBase

func (base *Base) InitializeBase(context *models.Context)

InitializeBase used for setting up base attributes for a mongo record

func (*Base) IsNewRecord

func (base *Base) IsNewRecord() bool

IsNewRecord used to check if record is new unsaved record

func (*Base) Reload

func (base *Base) Reload() error

Reload used to reload record from database

func (*Base) Save

func (base *Base) Save() error

Save used to save record in adapter

func (*Base) Store

func (base *Base) Store()

Store used to add record to list

func (*Base) StoreInList

func (base *Base) StoreInList(list *models.List)

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

func (query *Query) DestroyAll() error

DestroyAll used to destroy all records in collection with matching criterion

func (*Query) Each

func (query *Query) Each(handler func(models.Modellable, error) bool) error

Each used to iterate record 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) Sort added in v1.0.20

func (query *Query) Sort(field string, asc bool) models.Queryable

Sort used to sort collection

func (*Query) ToList

func (query *Query) ToList() *models.ListResults

ToList used to iterate record in collection with matching criterion

func (*Query) Where

func (query *Query) Where(filters helpers.H) models.Queryable

Where used to query collection

Jump to

Keyboard shortcuts

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