mongo

package
v0.0.0-...-a2093d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2022 License: LGPL-2.1 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestRepository

func NewTestRepository() *testRepository

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

Base Rewrite the methods provided in mongoc.Base to support modification, new automatic update time fields and soft delete. Soft delete is off by default; And the time is stored in the form of a timestamp. 重写 mongoc.Base 中提供的方法, 使其支持修改、新增自动更新时间字段和软删除, 默认关闭软删除, 且时间以时间戳形式存储

func NewMongoBase

func NewMongoBase(db string, collection string) *Base

func (*Base) Count

func (base *Base) Count(ctx context.Context, filter bson.M, opts ...*options.CountOptions) (int64, error)

func (*Base) DeleteMany

func (base *Base) DeleteMany(ctx context.Context, filter bson.M) error

func (*Base) DeleteOne

func (base *Base) DeleteOne(ctx context.Context, filter bson.M) error

func (*Base) Find

func (base *Base) Find(ctx context.Context, filter bson.M, results interface{}, opts ...*options.FindOptions) error

func (*Base) FindOne

func (base *Base) FindOne(ctx context.Context, filter bson.M, result interface{}, opts ...*options.FindOneOptions) error

func (*Base) InsertMany

func (base *Base) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func (*Base) InsertOne

func (base *Base) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*Base) Kernel

func (base *Base) Kernel() *mongoc.Base

Kernel If the rewriting part cannot meet the needs, use the original core Base 重写部分不能满足需求的则使用原核心 mongoc.Base

func (*Base) SetSoftDelete

func (base *Base) SetSoftDelete(softDelete bool) *Base

func (*Base) UpdateMany

func (base *Base) UpdateMany(ctx context.Context, filter bson.M, update bson.M, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*Base) UpdateOne

func (base *Base) UpdateOne(ctx context.Context, filter bson.M, update bson.M, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL