Versions in this module Expand all Collapse all v0 v0.1.0 Apr 2, 2023 Changes in this version + var DefaultConf = Conf + var ErrConflict = errors.New("Conflict") + var ErrForbidden = errors.New("Forbidden") + var ErrNoStorage = errors.New("No Storage Defined") + var ErrNotFound = errors.New("Not Found") + var ErrNotImplemented = errors.New("Not Implemented") + var Logger = func(ctx context.Context, level LogLevel, msg string, fields map[string]interface{}) + var LoggerLevel = LogLevelInfo + var ReadOnly = []Mode + var ReadWrite = []Mode + var WriteOnly = []Mode + type ClearEventHandler interface + OnClear func(ctx context.Context, q *query.Query) error + type ClearEventHandlerFunc func(ctx context.Context, q *query.Query) error + func (e ClearEventHandlerFunc) OnClear(ctx context.Context, q *query.Query) error + type ClearedEventHandler interface + OnCleared func(ctx context.Context, q *query.Query, deleted *int, err *error) + type ClearedEventHandlerFunc func(ctx context.Context, q *query.Query, deleted *int, err *error) + func (e ClearedEventHandlerFunc) OnCleared(ctx context.Context, q *query.Query, deleted *int, err *error) + type Compiler interface + Compile func() error + type Conf struct + AllowedModes []Mode + ForceTotal ForceTotalMode + PaginationDefaultLimit int + func (c Conf) IsModeAllowed(mode Mode) bool + type Counter interface + Count func(ctx context.Context, q *query.Query) (int, error) + type DeleteEventHandler interface + OnDelete func(ctx context.Context, item *Item) error + type DeleteEventHandlerFunc func(ctx context.Context, item *Item) error + func (e DeleteEventHandlerFunc) OnDelete(ctx context.Context, item *Item) error + type DeletedEventHandler interface + OnDeleted func(ctx context.Context, item *Item, err *error) + type DeletedEventHandlerFunc func(ctx context.Context, item *Item, err *error) + func (e DeletedEventHandlerFunc) OnDeleted(ctx context.Context, item *Item, err *error) + type FindEventHandler interface + OnFind func(ctx context.Context, q *query.Query) error + type FindEventHandlerFunc func(ctx context.Context, q *query.Query) error + func (e FindEventHandlerFunc) OnFind(ctx context.Context, q *query.Query) error + type ForceTotalMode int + const TotalAlways + const TotalDenied + const TotalOptIn + type FoundEventHandler interface + OnFound func(ctx context.Context, query *query.Query, list **ItemList, err *error) + type FoundEventHandlerFunc func(ctx context.Context, q *query.Query, list **ItemList, err *error) + func (e FoundEventHandlerFunc) OnFound(ctx context.Context, q *query.Query, list **ItemList, err *error) + type GetEventHandler interface + OnGet func(ctx context.Context, id interface{}) error + type GetEventHandlerFunc func(ctx context.Context, id interface{}) error + func (e GetEventHandlerFunc) OnGet(ctx context.Context, id interface{}) error + type GotEventHandler interface + OnGot func(ctx context.Context, item **Item, err *error) + type GotEventHandlerFunc func(ctx context.Context, item **Item, err *error) + func (e GotEventHandlerFunc) OnGot(ctx context.Context, item **Item, err *error) + type Index interface + Bind func(name string, s schema.Schema, h Storer, c Conf) *Resource + GetResource func(path string, parent *Resource) (*Resource, bool) + GetResources func() []*Resource + func NewIndex() Index + type InsertEventHandler interface + OnInsert func(ctx context.Context, items []*Item) error + type InsertEventHandlerFunc func(ctx context.Context, items []*Item) error + func (e InsertEventHandlerFunc) OnInsert(ctx context.Context, items []*Item) error + type InsertedEventHandler interface + OnInserted func(ctx context.Context, items []*Item, err *error) + type InsertedEventHandlerFunc func(ctx context.Context, items []*Item, err *error) + func (e InsertedEventHandlerFunc) OnInserted(ctx context.Context, items []*Item, err *error) + type Item struct + ETag string + ID interface{} + Payload map[string]interface{} + Updated time.Time + func NewItem(payload map[string]interface{}) (*Item, error) + func (i *Item) GetField(name string) interface{} + type ItemList struct + Items []*Item + Limit int + Offset int + Total int + type LogLevel int + const LogLevelDebug + const LogLevelError + const LogLevelFatal + const LogLevelInfo + const LogLevelWarn + type Mode int + const Clear + const Create + const Delete + const List + const Read + const Replace + const Update + type MultiGetter interface + MultiGet func(ctx context.Context, ids []interface{}) ([]*Item, error) + type Resource struct + func (r *Resource) Alias(name string, v url.Values) + func (r *Resource) Bind(name, field string, s schema.Schema, h Storer, c Conf) *Resource + func (r *Resource) Clear(ctx context.Context, q *query.Query) (deleted int, err error) + func (r *Resource) Compile(rc schema.ReferenceChecker) error + func (r *Resource) Conf() Conf + func (r *Resource) Delete(ctx context.Context, item *Item) (err error) + func (r *Resource) Find(ctx context.Context, q *query.Query) (list *ItemList, err error) + func (r *Resource) FindWithTotal(ctx context.Context, q *query.Query) (list *ItemList, err error) + func (r *Resource) Get(ctx context.Context, id interface{}) (item *Item, err error) + func (r *Resource) GetAlias(name string) (url.Values, bool) + func (r *Resource) GetAliases() []string + func (r *Resource) GetResources() []*Resource + func (r *Resource) Insert(ctx context.Context, items []*Item) (err error) + func (r *Resource) MultiGet(ctx context.Context, ids []interface{}) (items []*Item, err error) + func (r *Resource) Name() string + func (r *Resource) ParentField() string + func (r *Resource) Path() string + func (r *Resource) Schema() schema.Schema + func (r *Resource) Update(ctx context.Context, item *Item, original *Item) (err error) + func (r *Resource) Use(e interface{}) error + func (r *Resource) Validator() schema.Validator + type Storer interface + Clear func(ctx context.Context, q *query.Query) (int, error) + Delete func(ctx context.Context, item *Item) error + Find func(ctx context.Context, q *query.Query) (*ItemList, error) + Insert func(ctx context.Context, items []*Item) error + Update func(ctx context.Context, item *Item, original *Item) error + type UpdateEventHandler interface + OnUpdate func(ctx context.Context, item *Item, original *Item) error + type UpdateEventHandlerFunc func(ctx context.Context, item *Item, original *Item) error + func (e UpdateEventHandlerFunc) OnUpdate(ctx context.Context, item *Item, original *Item) error + type UpdatedEventHandler interface + OnUpdated func(ctx context.Context, item *Item, original *Item, err *error) + type UpdatedEventHandlerFunc func(ctx context.Context, item *Item, original *Item, err *error) + func (e UpdatedEventHandlerFunc) OnUpdated(ctx context.Context, item *Item, original *Item, err *error)