Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CloneError = errors.New("dummyCollection not support clone")
Functions ¶
func NewCustomRegistry ¶
NewCustomRegistry create custom registry
Types ¶
type Collection ¶
type Collection interface { Clone(opts ...*options.CollectionOptions) (*mongo.Collection, error) Name() string Database() *mongo.Database BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error) // InsertOne 插入一条 InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) // InsertMany 插入多条 InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error) // DeleteOne 删除一条 DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) // DeleteMany 删除多条 DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) // UpdateOne 更新一条 UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) // UpdateMany 更新多条 UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) // ReplaceOne 替换一条 ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error) // Aggregate 管道聚合操作 Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error) // CountDocuments 统计文档数量 CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error) EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error) Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error) // Find 自定义查询 Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error) // FindPage 分页查询 FindPage(ctx context.Context, filter interface{}, param *page.Params) (page.Page, error) // FindOne 查询一条 FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult // FindOneAndDelete 查询一条并删除 FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult // FindOneAndReplace 查询一条并替换 FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult // FindOneAndUpdate 查询一条并更新 FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error) Indexes() mongo.IndexView Drop(ctx context.Context) error }
Collection is a handle to a MongoDB collection. It is safe for concurrent use by multiple goroutines.
type DataBase ¶
type DataBase interface { // Name returns the name of the database. Name() string // Collection 获取文档集合 Collection(name string, opts ...*options.CollectionOptions) Collection }
type Info ¶
type Info struct { Addrs []string `toml:"Addrs" json:"Addrs"` Database string `toml:"Database" json:"Database"` Username string `toml:"Username" json:"Username"` Password string `toml:"pwd" json:"pwd"` MaxConn int `toml:"MaxConn" json:"MaxConn"` TimeOut int `toml:"TimeOut" json:"TimeOut"` // 超时时间, 单位秒 }
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
func (*Mongo) DefaultDatabase ¶
func (*Mongo) GetDatabase ¶
func (*Mongo) InitDefaultDatabase ¶
Click to show internal directories.
Click to hide internal directories.