Documentation ¶
Index ¶
- func InjectCreatePool(fun CreateConnectFunc)
- type CreateConnectFunc
- type DBInfo
- type Host
- type MongoConnect
- type MongoDB
- type MongoPool
- type MongoPooler
- type Options
- type Table
- func (t *Table) Aggregate(pipeline interface{}, result interface{})
- func (t *Table) CreateCollection()
- func (t *Table) DeleteMany(filter interface{}) *mongo.DeleteResult
- func (t *Table) DeleteOne(filter interface{}) *mongo.DeleteResult
- func (t *Table) Find(filter interface{}, result interface{})
- func (t *Table) FindOne(filter interface{}, result interface{})
- func (t *Table) InsertMany(documents []interface{}) []primitive.ObjectID
- func (t *Table) InsertOne(document interface{}) primitive.ObjectID
- func (t *Table) Pager(filter interface{}, result interface{}, page, pageSize int64)
- func (t *Table) ReplaceOne(filter interface{}, update interface{}) *mongo.UpdateResult
- func (t *Table) SetDB(db *MongoDB)
- func (t *Table) UpdateByID(id interface{}, update interface{}) *mongo.UpdateResult
- func (t *Table) UpdateMany(filter interface{}, update interface{}) *mongo.UpdateResult
- func (t *Table) UpdateOne(filter interface{}, update interface{}) *mongo.UpdateResult
- type Tabler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectCreatePool ¶
func InjectCreatePool(fun CreateConnectFunc)
InjectCreatePool 注入连接池的创建过程 connect 连接mongo配置 可以为空,如果为空需要自己创建数据连接查询配置后返回 fun 回调函数返回mongo连接配置
Types ¶
type CreateConnectFunc ¶
type CreateConnectFunc func(*MongoDB) []MongoConnect
CreateConnectFunc 创建连接
type DBInfo ¶
type DBInfo struct { Client *mongo.Client Database *mongo.Database Config MongoConnect }
DBInfo
type MongoConnect ¶
type MongoConnect struct { Name string `json:"name"` UserName string `json:"userName"` Password string `json:"password"` Hosts []Host `json:"hosts"` Database string `json:"database"` Option Options `json:"option"` ConnectTimeout int `json:"connectTimeout"` ExecuteTimeout int `json:"executeTimeout"` }
MongoConnect
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
MongoDB
type MongoPool ¶
type MongoPool struct {
// contains filtered or unexported fields
}
MongoPool
func (*MongoPool) AddConnects ¶
func (m *MongoPool) AddConnects(connects []MongoConnect)
AddConnects 添加多个连接
type MongoPooler ¶
type MongoPooler interface { GetDB(connectName string) *DBInfo Init(connect []MongoConnect) AddConnect(connect MongoConnect) AddConnects(connects []MongoConnect) }
MongoPooler
type Options ¶
type Options struct { ReplicaSet string `json:"replicaSet"` SlaveOk bool `json:"slaveOk"` Safe bool `json:"safe"` WtimeoutMS int64 `json:"wtimeoutMS"` ConnectTimeoutMS int64 `json:"connectTimeoutMS"` SocketTimeoutMS int64 `json:"socketTimeoutMS"` MaxPoolSize int `json:"maxPoolSize"` MinPoolSize int `json:"minPoolSize"` MaxIdleTimeMS int64 `json:"maxIdleTimeMS"` }
Options
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table 操作表
func (*Table) Aggregate ¶
func (t *Table) Aggregate(pipeline interface{}, result interface{})
Aggregate
func (*Table) DeleteMany ¶
func (t *Table) DeleteMany(filter interface{}) *mongo.DeleteResult
DeleteMany
func (*Table) DeleteOne ¶
func (t *Table) DeleteOne(filter interface{}) *mongo.DeleteResult
DeleteOne
func (*Table) InsertMany ¶
InsertMany
func (*Table) ReplaceOne ¶
func (t *Table) ReplaceOne(filter interface{}, update interface{}) *mongo.UpdateResult
ReplaceOne
func (*Table) UpdateByID ¶
func (t *Table) UpdateByID(id interface{}, update interface{}) *mongo.UpdateResult
UpdateByID
func (*Table) UpdateMany ¶
func (t *Table) UpdateMany(filter interface{}, update interface{}) *mongo.UpdateResult
UpdateMany
func (*Table) UpdateOne ¶
func (t *Table) UpdateOne(filter interface{}, update interface{}) *mongo.UpdateResult
UpdateOne
type Tabler ¶
type Tabler interface { SetDB(db *MongoDB) InsertOne(document interface{}) primitive.ObjectID InsertMany(documents []interface{}) []primitive.ObjectID UpdateOne(filter interface{}, update interface{}) *mongo.UpdateResult UpdateMany(filter interface{}, update interface{}) *mongo.UpdateResult UpdateByID(id interface{}, update interface{}) *mongo.UpdateResult ReplaceOne(filter interface{}, update interface{}) *mongo.UpdateResult DeleteOne(filter interface{}) *mongo.DeleteResult DeleteMany(filter interface{}) *mongo.DeleteResult FindOne(filter interface{}, result interface{}) Find(filter interface{}, result interface{}) Pager(filter interface{}, result interface{}, page, pageSize int64) Aggregate(pipeline interface{}, result interface{}) }
Tabler
func NewModelByConnectName ¶
NewModelByConnectName 新建一个模型
Click to show internal directories.
Click to hide internal directories.