Documentation ¶
Index ¶
- func AnyInSlice[T AnyInSliceType](v T, slice []T) bool
- func AnyPtr[T any](v T) *T
- func AnySet[T AnyInSliceType](list []T) []T
- func BatchInsertMany[T any](collection *qmgo.QmgoClient, ctx context.Context, models []T, batchSize int, ...) error
- func CreateIndex(ctx context.Context, qmgoClient *qmgo.QmgoClient, indexer Indexer) error
- func EnumInSlice[T EnumInSliceType](v T, slice []T) bool
- func ErrIsDup(err error) bool
- func MustNewMongoCollection(config MongoCollectionConf, model any) *qmgo.QmgoClient
- type AnyInSliceType
- type EnumInSliceType
- type Indexer
- type MongoCollectionConf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyInSlice ¶
func AnyInSlice[T AnyInSliceType](v T, slice []T) bool
func AnySet ¶
func AnySet[T AnyInSliceType](list []T) []T
func BatchInsertMany ¶
func BatchInsertMany[T any]( collection *qmgo.QmgoClient, ctx context.Context, models []T, batchSize int, opts ...opts.InsertManyOptions, ) error
BatchInsertMany 批量插入 防止一次插入太多数据 mongodb限制一次插入的数据量
func CreateIndex ¶
func EnumInSlice ¶
func EnumInSlice[T EnumInSliceType](v T, slice []T) bool
func MustNewMongoCollection ¶
func MustNewMongoCollection(config MongoCollectionConf, model any) *qmgo.QmgoClient
Types ¶
type AnyInSliceType ¶
type EnumInSliceType ¶
type EnumInSliceType interface {
String() string
}
type Indexer ¶
type Indexer interface {
GetIndexes() []opts.IndexModel
}
type MongoCollectionConf ¶
type MongoCollectionConf struct { // Uri is the connection URI for the mongo instance // example: mongodb://$user:$pwd@$host:$port // example: mongodb://172.88.10.41:27017/?replicaSet=rs0 Uri string Database string Collection string MaxPoolSize uint64 `json:",default=100"` MinPoolSize uint64 `json:",optional"` SocketTimeoutMS int64 `json:",default=300000"` // default is 5 minutes //ReadPreference 读偏好模式 //DefaultMode:0 默认不设置 //PrimaryMode:1 从主节点读取数据 //PrimaryPreferredMode:2 优先从主节点读取数据,如果主节点不可用,从从节点读取数据 //SecondaryMode:3 从从节点读取数据 //SecondaryPreferredMode:4 优先从从节点读取数据,如果从节点不可用,从主节点读取数据 //NearestMode:5 从最近的成员读取数据 ReadPreference int `json:",optional"` // default is primary }
Click to show internal directories.
Click to hide internal directories.