mongoClientPool

package
v1.7.8 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data = primitive.D

type Entity

type Entity = primitive.E

type Map

type Map = primitive.M

type MongoClient

type MongoClient struct {
	CurrentDatabase   *mongo.Database
	CurrentCollection *mongo.Collection

	Err error
	// contains filtered or unexported fields
}

func NewMongoClient

func NewMongoClient(url string) (*MongoClient, error)

NewMongoClient 实例化:mongo客户端

func (*MongoClient) Aggregate

func (my *MongoClient) Aggregate(results any) *MongoClient

Aggregate 聚合查询

func (*MongoClient) CleanConditions

func (my *MongoClient) CleanConditions()

CleanConditions 清理查询条件

func (*MongoClient) Close

func (my *MongoClient) Close() error

Close 关闭客户端

func (*MongoClient) DeleteMany

func (my *MongoClient) DeleteMany(res **mongo.DeleteResult) *MongoClient

DeleteMany 删除多条数据

func (*MongoClient) DeleteOne

func (my *MongoClient) DeleteOne(res **mongo.DeleteResult) *MongoClient

DeleteOne 删除单条数据

func (*MongoClient) FindMany

func (my *MongoClient) FindMany(results any, findOptionFn func(opt *options.FindOptions) *options.FindOptions) *MongoClient

FindMany 查询多条数据

func (*MongoClient) FindOne

func (my *MongoClient) FindOne(result any, findOneOptionFn func(opt *options.FindOneOptions) *options.FindOneOptions) *MongoClient

FindOne 查询一条数据

func (*MongoClient) GetClient

func (my *MongoClient) GetClient() *mongo.Client

GetClient 获取客户端链接

func (*MongoClient) GetConditions

func (my *MongoClient) GetConditions() []Map

GetConditions 获取全部查询条件(聚合条件)

func (*MongoClient) GetFirstCondition

func (my *MongoClient) GetFirstCondition() Map

GetFirstCondition 获取第一个查询条件(非聚合条件)

func (*MongoClient) InsertMany

func (my *MongoClient) InsertMany(data []any, res **mongo.InsertManyResult) *MongoClient

InsertMany 插入多条数据

func (*MongoClient) InsertOne

func (my *MongoClient) InsertOne(data any, res **mongo.InsertOneResult) *MongoClient

InsertOne 插入一条数据

func (*MongoClient) Ping

func (my *MongoClient) Ping() error

Ping 测试链接

func (*MongoClient) SetCollection

func (my *MongoClient) SetCollection(collection string, opts ...*options.CollectionOptions) *MongoClient

SetCollection 设置文档

func (*MongoClient) SetDatabase

func (my *MongoClient) SetDatabase(database string, opts ...*options.DatabaseOptions) *MongoClient

SetDatabase 设置数据库

func (*MongoClient) UpdateMany

func (my *MongoClient) UpdateMany(data any, res **mongo.UpdateResult, opts ...*options.UpdateOptions) *MongoClient

UpdateMany 修改多条数据

func (*MongoClient) UpdateOne

func (my *MongoClient) UpdateOne(data any, res **mongo.UpdateResult, opts ...*options.UpdateOptions) *MongoClient

UpdateOne 修改一条数据

func (*MongoClient) Where

func (my *MongoClient) Where(condition ...Map) *MongoClient

Where 设置查询条件

type MongoClientPool

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

func OnceMongoPool

func OnceMongoPool() *MongoClientPool

OnceMongoPool 单例化:mongodb连接池

func (*MongoClientPool) AppendClient

func (*MongoClientPool) AppendClient(key string, mongoClient *MongoClient) (*MongoClientPool, error)

AppendClient 增加客户端

func (*MongoClientPool) Clean

func (*MongoClientPool) Clean() *MongoClientPool

Clean 清理客户端

func (*MongoClientPool) GetClient

func (*MongoClientPool) GetClient(key string) *MongoClient

GetClient 获取客户端

func (*MongoClientPool) HasClient

func (*MongoClientPool) HasClient(key string) bool

HasClient 检查客户端是否存在

func (*MongoClientPool) Remove

func (*MongoClientPool) Remove(key string) (*MongoClientPool, error)

清除客户端

type OID

type OID = primitive.ObjectID

Jump to

Keyboard shortcuts

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