Documentation ¶
Index ¶
- type Adapter
- type Base
- func (base *Base) Cache()
- func (base *Base) Destroy() error
- func (base *Base) GetCollectionName() string
- func (base *Base) GetHooksHandler() *HooksHandler
- func (base *Base) GetID() string
- func (base *Base) Initialize(collection *Collection, hooksHandler *HooksHandler, item Modellable)
- func (base *Base) IsNewRecord() bool
- func (base *Base) Reload() error
- func (base *Base) Save() error
- type Collection
- type CollectionCacher
- func (cacher *CollectionCacher) Count() int
- func (cacher *CollectionCacher) Find(predicate FindPredicate) Modellable
- func (cacher *CollectionCacher) FindAll(predicate FindPredicate) []Modellable
- func (cacher *CollectionCacher) FindByID(id string) Modellable
- func (cacher *CollectionCacher) First() Modellable
- func (cacher *CollectionCacher) GetItems() []Modellable
- type FindPredicate
- type FiniteStateMachine
- func (fsm *FiniteStateMachine) AddStateHandler(stateName string, enterHandler func(string), runHandler func(), ...)
- func (fsm *FiniteStateMachine) Equals(stateName string) bool
- func (fsm *FiniteStateMachine) GetActiveAgent() interface{}
- func (fsm *FiniteStateMachine) GetEndAt() int64
- func (fsm *FiniteStateMachine) GetName() string
- func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)
- func (fsm *FiniteStateMachine) IsTurnExpired() bool
- func (fsm *FiniteStateMachine) Run(item Modellable)
- func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)
- type HooksHandler
- type Manager
- type Modellable
- type NewHandler
- type Query
- func (query *Query) Count() (int64, error)
- func (query *Query) DestroyAll() error
- func (query *Query) Each(handler func(Modellable, error)) error
- func (query *Query) Find(id string) (Modellable, error)
- func (query *Query) First() (Modellable, error)
- func (query *Query) FirstOrCreate(values helpers.H) (Modellable, error)
- func (query *Query) Where(filters bson.M) *Query
- type Queryable
- type StateHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶ added in v0.0.39
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is adapter for mongo
type Base ¶
type Base struct { ID primitive.ObjectID `bson:"_id" json:"id"` CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` // contains filtered or unexported fields }
Base used to represent base classes for all models
func (*Base) GetCollectionName ¶ added in v0.0.26
GetCollectionName used to retrieve collection's name
func (*Base) GetHooksHandler ¶ added in v0.0.39
func (base *Base) GetHooksHandler() *HooksHandler
GetHooksHandler used to retrieve hooks handler
func (*Base) Initialize ¶ added in v0.0.21
func (base *Base) Initialize(collection *Collection, hooksHandler *HooksHandler, item Modellable)
Initialize used for setting up base attributes for a mongo record
func (*Base) IsNewRecord ¶ added in v0.0.39
IsNewRecord used to check if record is new unsaved record
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection used to contain models
func (*Collection) Create ¶
func (collection *Collection) Create(values helpers.H) (Modellable, error)
Create used to create item
func (*Collection) New ¶ added in v0.0.39
func (collection *Collection) New(values helpers.H) Modellable
New used to initialize item
func (*Collection) Query ¶ added in v0.0.39
func (collection *Collection) Query() *Query
Query returns query wrapper for retrieving records in adapter
type CollectionCacher ¶ added in v0.0.39
type CollectionCacher struct {
// contains filtered or unexported fields
}
func (*CollectionCacher) Count ¶ added in v0.0.39
func (cacher *CollectionCacher) Count() int
Count used to count items
func (*CollectionCacher) Find ¶ added in v0.0.39
func (cacher *CollectionCacher) Find(predicate FindPredicate) Modellable
Find used to find item in collection, return nil if not found
func (*CollectionCacher) FindAll ¶ added in v0.0.39
func (cacher *CollectionCacher) FindAll(predicate FindPredicate) []Modellable
FindAll used to find items in collection
func (*CollectionCacher) FindByID ¶ added in v0.0.39
func (cacher *CollectionCacher) FindByID(id string) Modellable
FindByID used to find item in collection by id, return nil if not found
func (*CollectionCacher) First ¶ added in v0.0.39
func (cacher *CollectionCacher) First() Modellable
First used to return first item in collection
func (*CollectionCacher) GetItems ¶ added in v0.0.39
func (cacher *CollectionCacher) GetItems() []Modellable
GetItems used to return all items in collections
type FindPredicate ¶ added in v0.0.21
type FindPredicate func(Modellable) bool
FindPredicate is alias for func(Modellable) bool
type FiniteStateMachine ¶
type FiniteStateMachine struct {
// contains filtered or unexported fields
}
FiniteStateMachine used to implement fsm
func MakeFiniteStateMachine ¶
func MakeFiniteStateMachine(defaultStateName string) *FiniteStateMachine
MakeFiniteStateMachine used to instantiate fsm
func (*FiniteStateMachine) AddStateHandler ¶
func (fsm *FiniteStateMachine) AddStateHandler( stateName string, enterHandler func(string), runHandler func(), exitHandler func(), )
AddStateHandler used to add handler for fsm's state
func (*FiniteStateMachine) Equals ¶
func (fsm *FiniteStateMachine) Equals(stateName string) bool
Equals used to compare fsm's state
func (*FiniteStateMachine) GetActiveAgent ¶
func (fsm *FiniteStateMachine) GetActiveAgent() interface{}
GetActiveAgent used to get fsm's active agent at current turn
func (*FiniteStateMachine) GetEndAt ¶
func (fsm *FiniteStateMachine) GetEndAt() int64
GetEndAt used to get turn's end time
func (*FiniteStateMachine) GetName ¶
func (fsm *FiniteStateMachine) GetName() string
GetName used to get fsm's state name
func (*FiniteStateMachine) GoTo ¶
func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)
GoTo used for fsm's state transition
func (*FiniteStateMachine) IsTurnExpired ¶
func (fsm *FiniteStateMachine) IsTurnExpired() bool
IsTurnExpired used to check if turn is expired
func (*FiniteStateMachine) Run ¶
func (fsm *FiniteStateMachine) Run(item Modellable)
Run used to run fsm's state
func (*FiniteStateMachine) SetTurn ¶
func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)
SetTurn used to set new turn
type HooksHandler ¶ added in v0.0.39
type HooksHandler struct {
// contains filtered or unexported fields
}
HooksHandler used to mange callbacks for models
func (*HooksHandler) RegisterAfterInitializeHook ¶ added in v0.0.39
func (handler *HooksHandler) RegisterAfterInitializeHook(afterInitializeHook func(*helpers.Dictionary))
RegisterAfterInitializeHook used to add after initialize hook
func (*HooksHandler) RegisterValidationHook ¶ added in v0.0.39
func (handler *HooksHandler) RegisterValidationHook(validationHook func() error)
RegisterValidationHook used to add a validation hook
type Manager ¶ added in v0.0.22
type Manager struct {
// contains filtered or unexported fields
}
Manager is a singleton used to manager model's behavior
func (*Manager) CreateCollection ¶ added in v0.0.23
func (manager *Manager) CreateCollection(collectionName string, newHandler NewHandler) *Collection
CreateCollection used to create a collection for models manager
func (*Manager) RegisterAdapter ¶ added in v0.0.39
type Modellable ¶ added in v0.0.21
type Modellable interface { Initialize(*Collection, *HooksHandler, Modellable) Save() error GetID() string GetHooksHandler() *HooksHandler }
Modellable is the interface for all models implementing model's functionalities
type NewHandler ¶ added in v0.0.39
type NewHandler func(*Collection, *HooksHandler) Modellable
NewHandler is alias for func(args ...interface{}) Modellable
type Query ¶ added in v0.0.39
type Query struct {
// contains filtered or unexported fields
}
Query is a wrapper for querying mongo
func (*Query) Count ¶ added in v0.0.39
Count used to count records in collection with matching criterion
func (*Query) DestroyAll ¶ added in v0.0.39
func (*Query) Each ¶ added in v0.0.39
func (query *Query) Each(handler func(Modellable, error)) error
Each used to iterate record in collection with matching criterion
func (*Query) First ¶ added in v0.0.39
func (query *Query) First() (Modellable, error)
First used to return first record in collection with matching criterion
func (*Query) FirstOrCreate ¶ added in v0.0.39
func (query *Query) FirstOrCreate(values helpers.H) (Modellable, error)
type Queryable ¶ added in v0.0.39
Queryable is the interface for all query adapter implementing query's functionalities
type StateHandler ¶
type StateHandler struct {
// contains filtered or unexported fields
}
StateHandler used to