mongoPool

package
v1.6.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Demo added in v1.6.5

func Demo()

Types

type Data added in v1.6.3

type Data = primitive.D

func NewData added in v1.6.3

func NewData(kv ...Entity) Data

NewData 新建单条数据

type Entity added in v1.6.5

type Entity = primitive.E

func NewEntity added in v1.6.5

func NewEntity(Key string, Value any) Entity

NewEntity 新建实体数据

type Map added in v1.6.3

type Map = primitive.M

func NewMap added in v1.6.3

func NewMap(Key string, Value any) Map

NewMap 新建Map数据

type MongoClient

type MongoClient struct {
	Err error
	// contains filtered or unexported fields
}

func NewMongoClient

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

NewMongoClient 实例化:mongo客户端

func (*MongoClient) CleanCondition added in v1.6.5

func (my *MongoClient) CleanCondition()

CleanCondition 清理查询条件

func (*MongoClient) Close

func (my *MongoClient) Close() error

Close 关闭客户端

func (*MongoClient) DeleteMany added in v1.6.3

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

DeleteMany 删除多条数据

func (*MongoClient) DeleteOne added in v1.6.3

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

DeleteOne 删除单条数据

func (*MongoClient) FindMany added in v1.6.3

func (my *MongoClient) FindMany(results *[]Map, findOptionFn func(opt *options.FindOptions) *options.FindOptions) *MongoClient

FindMany 查询多条数据

func (*MongoClient) FindOne added in v1.6.3

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

FindOne 查询一条数据

func (*MongoClient) GetClient

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

GetClient 获取客户端链接

func (*MongoClient) InsertMany added in v1.6.3

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

InsertMany 插入多条数据

func (*MongoClient) InsertOne added in v1.6.3

func (my *MongoClient) InsertOne(data Data) *mongo.InsertOneResult

InsertOne 插入一条数据

func (*MongoClient) Ping added in v1.6.3

func (my *MongoClient) Ping()

Ping 测试链接

func (*MongoClient) SetCollection added in v1.6.3

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

SetCollection 设置文档

func (*MongoClient) SetDatabase added in v1.6.3

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

SetDatabase 设置数据库

func (*MongoClient) Where added in v1.6.3

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 added in v1.6.5

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

AppendClient 增加客户端

func (*MongoClientPool) Clean

func (*MongoClientPool) Clean() *MongoClientPool

Clean 清理客户端

func (*MongoClientPool) GetClient added in v1.6.3

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

GetClient 获取客户端

func (*MongoClientPool) HasClient added in v1.6.3

func (*MongoClientPool) HasClient(key string) bool

HasClient 检查客户端是否存在

func (*MongoClientPool) Remove

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

清除客户端

Jump to

Keyboard shortcuts

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