Documentation
¶
Index ¶
- func ConvertSortParameters(params api.SortParameters) []string
- func NewCRUDTable(session *mgo.Session, db, table string) api.EntityCRUD
- type Default
- func (d *Default) Delete(id interface{}) error
- func (d *Default) DeleteAll(pred interface{}) error
- func (d *Default) Find(id interface{}, value interface{}) error
- func (d *Default) FindBy(key string, value interface{}, results interface{}) error
- func (d *Default) FindByAndCount(key string, value interface{}) (int, error)
- func (d *Default) FindByAndFetch(key string, value interface{}, results interface{}) error
- func (d *Default) FindFetchOne(id string, value interface{}) error
- func (d *Default) FindOneBy(key string, value interface{}, result interface{}) error
- func (d *Default) GetDBName() string
- func (d *Default) GetSession() interface{}
- func (d *Default) GetTable() interface{}
- func (d *Default) GetTableName() string
- func (d *Default) Insert(data interface{}) error
- func (d *Default) InsertOrUpdate(id interface{}, data interface{}) error
- func (d *Default) List(results interface{}, sortParams *api.SortParameters, ...) error
- func (d *Default) Search(results interface{}, filter interface{}, sortParams *api.SortParameters, ...) error
- func (d *Default) Update(selector interface{}, data interface{}) error
- func (d *Default) UpdateID(id interface{}, data interface{}) error
- func (d *Default) Where(filter interface{}, results interface{}) error
- func (d *Default) WhereAndFetch(filter interface{}, results interface{}) error
- func (d *Default) WhereAndFetchLimit(filter interface{}, paginator *api.Pagination, results interface{}) error
- func (d *Default) WhereAndFetchOne(filter interface{}, result interface{}) error
- func (d *Default) WhereCount(filter interface{}) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertSortParameters ¶
func ConvertSortParameters(params api.SortParameters) []string
ConvertSortParameters to mongodb query string
func NewCRUDTable ¶
func NewCRUDTable(session *mgo.Session, db, table string) api.EntityCRUD
NewCRUDTable sets up a new Default struct
Types ¶
type Default ¶
type Default struct {
// contains filtered or unexported fields
}
Default contains the basic implementation of the MongoCRUD interface
func (*Default) FindBy ¶
FindBy is an utility for fetching values if they are stored in a key-value manenr.
func (*Default) FindByAndCount ¶
FindByAndCount returns the number of elements that match the filter
func (*Default) FindByAndFetch ¶
FindByAndFetch retrieves a value by key and then fills results with the result.
func (*Default) FindFetchOne ¶
FindFetchOne searches for a resource and then unmarshals the first row into value
func (*Default) FindOneBy ¶
FindOneBy is an utility for fetching values if they are stored in a key-value manenr.
func (*Default) GetSession ¶
func (d *Default) GetSession() interface{}
GetSession returns the current session
func (*Default) GetTable ¶
func (d *Default) GetTable() interface{}
GetTable returns the table as a mgo.Collection
func (*Default) GetTableName ¶
GetTableName returns table's name
func (*Default) InsertOrUpdate ¶
InsertOrUpdate inserts or update document if exists
func (*Default) List ¶
func (d *Default) List(results interface{}, sortParams *api.SortParameters, pagination *api.Pagination) error
List all entities from the database
func (*Default) Search ¶
func (d *Default) Search(results interface{}, filter interface{}, sortParams *api.SortParameters, pagination *api.Pagination) error
Search all entities from the database
func (*Default) UpdateID ¶
UpdateID performs an update on an existing resource with ID that equals the id argument
func (*Default) WhereAndFetch ¶
WhereAndFetch filters with multiple fields and then fills results with all found resources
func (*Default) WhereAndFetchLimit ¶
func (d *Default) WhereAndFetchLimit(filter interface{}, paginator *api.Pagination, results interface{}) error
WhereAndFetchLimit filters with multiple fields and then fills results with all found resources
func (*Default) WhereAndFetchOne ¶
WhereAndFetchOne filters with multiple fields and then fills result with the first found resource
func (*Default) WhereCount ¶
WhereCount allows counting with multiple fields