Documentation ¶
Index ¶
- func Connection(ctx context.Context, cfg *Configuration) (*mongowrapper.WrappedClient, error)
- func ConvertSortParameters(params db.SortParameters) []string
- func Transaction(ctx context.Context, client *mongowrapper.WrappedClient, fn TransactionFunc) error
- type Configuration
- type Default
- func (d *Default) Delete(ctx context.Context, id interface{}) error
- func (d *Default) DeleteAll(ctx context.Context, pred interface{}) error
- func (d *Default) Find(ctx context.Context, id interface{}, value interface{}) error
- func (d *Default) FindBy(ctx context.Context, key string, value interface{}, results interface{}) error
- func (d *Default) FindByAndCount(ctx context.Context, key string, value interface{}) (int64, error)
- func (d *Default) FindByAndFetch(ctx context.Context, key string, value interface{}, results interface{}) error
- func (d *Default) FindFetchOne(ctx context.Context, id string, value interface{}) error
- func (d *Default) FindOneBy(ctx context.Context, 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(ctx context.Context, data interface{}) error
- func (d *Default) InsertOrUpdate(ctx context.Context, id interface{}, data interface{}) error
- func (d *Default) List(ctx context.Context, results interface{}, sortParams *db.SortParameters, ...) error
- func (d *Default) Search(ctx context.Context, results interface{}, filter interface{}, ...) error
- func (d *Default) Update(ctx context.Context, selector interface{}, data interface{}) error
- func (d *Default) UpdateID(ctx context.Context, id interface{}, data interface{}) error
- func (d *Default) Where(ctx context.Context, filter interface{}, results interface{}) error
- func (d *Default) WhereAndFetchLimit(ctx context.Context, filter interface{}, paginator *db.Pagination, ...) error
- func (d *Default) WhereAndFetchOne(ctx context.Context, filter interface{}, result interface{}) error
- func (d *Default) WhereCount(ctx context.Context, filter interface{}) (int64, error)
- type TransactionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connection ¶
func Connection(ctx context.Context, cfg *Configuration) (*mongowrapper.WrappedClient, error)
Connection provides Wire provider for a MongoDB database connection
func ConvertSortParameters ¶
func ConvertSortParameters(params db.SortParameters) []string
ConvertSortParameters to sql query string
func Transaction ¶
func Transaction(ctx context.Context, client *mongowrapper.WrappedClient, fn TransactionFunc) error
Transaction runs the transactionfunc in a transaction
Types ¶
type Configuration ¶
type Configuration struct { AutoMigrate bool ConnectionString string DatabaseName string Username string Password string }
Configuration repesents database connection configuration
type Default ¶
type Default struct {
// contains filtered or unexported fields
}
Default contains the basic implementation of the MongoCRUD interface
func NewCRUDTable ¶
func NewCRUDTable(session *mongowrapper.WrappedClient, db, table string) *Default
NewCRUDTable sets up a new Default struct
func (*Default) FindBy ¶
func (d *Default) FindBy(ctx context.Context, key string, value interface{}, results interface{}) error
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 ¶
func (d *Default) FindByAndFetch(ctx context.Context, key string, value interface{}, results interface{}) error
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 ¶
func (d *Default) FindOneBy(ctx context.Context, key string, value interface{}, result interface{}) error
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(ctx context.Context, results interface{}, sortParams *db.SortParameters, pagination *db.Pagination) error
List all entities from the database
func (*Default) Search ¶
func (d *Default) Search(ctx context.Context, results interface{}, filter interface{}, sortParams *db.SortParameters, pagination *db.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) WhereAndFetchLimit ¶
func (d *Default) WhereAndFetchLimit(ctx context.Context, filter interface{}, paginator *db.Pagination, results interface{}) error
WhereAndFetchLimit filters with multiple fields and then fills results with all found resources
type TransactionFunc ¶
type TransactionFunc func() error
TransactionFunc is the transaction handler closure contract