Documentation ¶
Index ¶
- Constants
- Variables
- type AggregateKey
- type AggregateKeys
- type AggregateOperator
- type BaseMongoDBClient
- type BulkWriteResult
- type DataType
- type Filter
- type Filters
- type GroupKey
- type GroupKeys
- type MongoDB
- func (db *MongoDB) BulkWrite(ctx context.Context, collection string, data []mongo.WriteModel) (*mongo.BulkWriteResult, error)
- func (db *MongoDB) Count(ctx context.Context, collection string, filters Filters) (int, error)
- func (db *MongoDB) Delete(ctx context.Context, collection string, filters Filters) (deletedCount int64, err error)
- func (db *MongoDB) DeleteMany(ctx context.Context, collection string, filters Filters) (deletedCount int64, err error)
- func (db *MongoDB) Distinct(ctx context.Context, collection string, fieldName string, filters Filters) ([]interface{}, error)
- func (db *MongoDB) FindOneAndUpdate(ctx context.Context, collection string, filters Filters, updates Updates, ...) error
- func (db *MongoDB) Get(ctx context.Context, collection string, filters Filters, offset string, ...) (string, error)
- func (db *MongoDB) GetAggregate(ctx context.Context, collection string, filters Filters, groupKeys GroupKeys, ...) (interface{}, error)
- func (db *MongoDB) GetCursor(ctx context.Context, collection string, filters Filters, sortKeys []SortKey, ...) (interface{}, error)
- func (db *MongoDB) GetOne(ctx context.Context, collection string, filters Filters, ...) error
- func (db *MongoDB) GetReaderDB() (interface{}, error)
- func (db *MongoDB) GetSorted(ctx context.Context, collection string, filters Filters, offset string, ...) (string, error)
- func (db *MongoDB) GetWriterDB() (interface{}, error)
- func (db *MongoDB) Insert(ctx context.Context, collection string, data interface{}) error
- func (db *MongoDB) InsertMany(ctx context.Context, collection string, data []interface{}) error
- func (db *MongoDB) Replace(ctx context.Context, collection string, filters Filters, data interface{}) error
- func (db *MongoDB) Update(ctx context.Context, collection string, filters Filters, updates Updates) error
- func (db *MongoDB) Upsert(ctx context.Context, collection string, filters Filters, updates Updates) error
- type Operator
- type Order
- type Projection
- type Range
- type SortKey
- type Update
- type UpdateOperator
- type Updates
Constants ¶
View Source
const ( Get dbOperation = "Get" GetOne dbOperation = "GetOne" GetSorted dbOperation = "GetSorted" GetAggregate dbOperation = "GetAggregate" Insert dbOperation = "Insert" InsertMany dbOperation = "InsertMany" Upsert dbOperation = "Upsert" Replace dbOperation = "Replace" Count dbOperation = "Count" GetCursor dbOperation = "GetCursor" BulkUpsert dbOperation = "BulkUpsert" BulkWrite dbOperation = "BulkWrite" FindOneAndUpdate dbOperation = "FindOneAndUpdate" DeleteMany dbOperation = "DeleteMany" GetDistinct dbOperation = "GetDistinct" Delete dbOperation = "Delete" )
Variables ¶
View Source
var NoItemFound = mongo.ErrNoDocuments
Functions ¶
This section is empty.
Types ¶
type AggregateKey ¶
type AggregateKey struct { Key string Operator AggregateOperator Value string }
AggregateKey represents a fiedl which needs to be aggregated
type AggregateKeys ¶
type AggregateKeys []AggregateKey
AggregateKeys : array of AggregateKey
func (*AggregateKeys) Append ¶
func (a *AggregateKeys) Append(aggregateKeys ...AggregateKey)
Append append function
type AggregateOperator ¶
type AggregateOperator uint16
AggregateOperator operators used
const ( SUM AggregateOperator = 1 MIN AggregateOperator = 2 MAX AggregateOperator = 3 )
type BaseMongoDBClient ¶
type BaseMongoDBClient interface { Insert(ctx context.Context, table string, data interface{}) (err error) InsertMany(ctx context.Context, table string, data []interface{}) (err error) Get(ctx context.Context, table string, filters Filters, offset string, limit int64, result interface{}) (next string, err error) GetSorted(ctx context.Context, table string, filters Filters, offset string, limit int64, sortKey []SortKey, results interface{}) (next string, err error) GetOne(ctx context.Context, table string, filters Filters, result interface{}) (err error) Update(ctx context.Context, table string, filters Filters, updates Updates) (err error) BulkWrite(ctx context.Context, table string, data []mongo.WriteModel) (*mongo.BulkWriteResult, error) Upsert(ctx context.Context, table string, filters Filters, updates Updates) (err error) Replace(ctx context.Context, table string, filters Filters, data interface{}) (err error) Count(ctx context.Context, table string, filters Filters) (count int, err error) Delete(ctx context.Context, table string, filters Filters) (deletedCount int64, err error) GetReaderDB() (db interface{}, err error) GetWriterDB() (db interface{}, err error) FindOneAndUpdate(ctx context.Context, table string, filters Filters, updates Updates, result interface{}) (err error) GetCursor(ctx context.Context, table string, filters Filters, sortKeys []SortKey, projections interface{}) (cursor interface{}, err error) GetAggregate(ctx context.Context, collection string, filters Filters, groupKeys GroupKeys, aggregateKeys AggregateKeys) (cursor interface{}, err error) DeleteMany(ctx context.Context, collection string, filters Filters) (deletedCount int64, err error) Distinct(ctx context.Context, collection string, fieldName string, filters Filters) (result []interface{}, err error) }
type BulkWriteResult ¶
type BulkWriteResult struct { mongo.BulkWriteResult Err error }
type GroupKey ¶
type GroupKey struct { Key string Value interface{} }
GroupKey represents a field by which we group
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
func (*MongoDB) BulkWrite ¶
func (db *MongoDB) BulkWrite(ctx context.Context, collection string, data []mongo.WriteModel) (*mongo.BulkWriteResult, error)
func (*MongoDB) DeleteMany ¶
func (*MongoDB) FindOneAndUpdate ¶
func (db *MongoDB) FindOneAndUpdate(ctx context.Context, collection string, filters Filters, updates Updates, result interface{}) error
FindOneAndUpdate
func (*MongoDB) Get ¶
func (db *MongoDB) Get(ctx context.Context, collection string, filters Filters, offset string, limit int64, results interface{}) (string, error)
Get ...
func (*MongoDB) GetAggregate ¶
func (*MongoDB) GetCursor ¶
func (db *MongoDB) GetCursor(ctx context.Context, collection string, filters Filters, sortKeys []SortKey, projections interface{}) (interface{}, error)
GetCursor ...
func (*MongoDB) GetOne ¶
func (db *MongoDB) GetOne(ctx context.Context, collection string, filters Filters, projections []Projection, result interface{}) error
GetOne ...
func (*MongoDB) GetSorted ¶
func (db *MongoDB) GetSorted(ctx context.Context, collection string, filters Filters, offset string, limit int64, sortKeys []SortKey, results interface{}) (string, error)
GetSorted ... eg. sortKeys := make(db.SortKeys)
sortKeys["created_at"] = db.DSC sortKeys["name"] = db.ASC
func (*MongoDB) InsertMany ¶
InsertMany ...
func (*MongoDB) Replace ¶
func (db *MongoDB) Replace(ctx context.Context, collection string, filters Filters, data interface{}) error
Replace ...
type Projection ¶
type Projection struct { Key string Value interface{} }
type Update ¶
type Update struct { Key string Value interface{} Type DataType UpdateOperator UpdateOperator }
Update used to Update data
type UpdateOperator ¶
type UpdateOperator string
UpdateOperator operators used
const ( SET UpdateOperator = "$set" UNSET UpdateOperator = "$unset" PUSH UpdateOperator = "$push" PULL UpdateOperator = "$pull" INC UpdateOperator = "$inc" ARRAY_IN UpdateOperator = "$in" NOT UpdateOperator = "$not" )
func (UpdateOperator) ToString ¶
func (u UpdateOperator) ToString() string
Click to show internal directories.
Click to hide internal directories.