Documentation ¶
Index ¶
Constants ¶
View Source
const (
SortDescending = -1
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { GetCollection(collection string) *mongo.Collection FindById(ctx context.Context, collection string, id string, result interface{}) error FindOne(ctx context.Context, collection string, result interface{}, opts ...Option) error Find(ctx context.Context, collection string, result interface{}, opts ...Option) error UpdateMany(ctx context.Context, collection string, filter, update interface{}, options *options.UpdateOptions) error UpdateOne(ctx context.Context, collection string, filter, update interface{}, options *options.UpdateOptions) error UpdateOneRaw(ctx context.Context, collection string, filter, update interface{}, options *options.UpdateOptions) error UpdateManyRaw(ctx context.Context, collection string, filter, update interface{}, options *options.UpdateOptions) error Insert(ctx context.Context, collection string, document interface{}) error EnsureIndexes(ctx context.Context, collection string, model []mongo.IndexModel) error Delete(ctx context.Context, collection string, filter interface{}, opts *options.DeleteOptions) error WithTransaction(callback func(sc mongo.SessionContext) (interface{}, error)) (interface{}, error) FindOneAndUpdate(ctx context.Context, collection string, filter, update interface{}, opts *options.FindOneAndUpdateOptions, result interface{}) error Count(ctx context.Context, collection string, filter interface{}, opts ...*options.CountOptions) (int64, error) BulkWriteRaw(ctx context.Context, collection string, operations []mongo.WriteModel, opts ...*options.BulkWriteOptions) error Close() }
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithFilter ¶
func WithFilter(filter interface{}) Option
WithFilter - default not filter
Use bson object to filter document ¶
see more: https://docs.mongodb.com/manual/reference/operator/query/
func WithPaging ¶
func WithPaging(dPaging *paging.Pagination) Option
func WithSorter ¶
func WithSorter(sorter interface{}) Option
WithSorter - default sort descending by `_id` field
{ $sort: { <field1>: <sort order>, <field2>: <sort order> ... }}
$sort takes a document that specifies the field(s) to sort by and the respective sort order. <sort order> can have one of the following values:
1 Sort ascending
-1 Sort descending
{ $meta: "textScore" } Sort by the computed textScore metadata in descending order
Click to show internal directories.
Click to hide internal directories.