Documentation ¶
Index ¶
- func InitClients()
- func StringsToBsonId(ids []string) (objectIds []primitive.ObjectID)
- type BulkUpdateItem
- type BulkUpsertItem
- type Client
- func (client *Client) Aggregate(ctx context.Context, collection *mongo.Collection, pipeline interface{}, ...) error
- func (client *Client) BatchInsert(ctx context.Context, collection *mongo.Collection, data []interface{}, ...) error
- func (client *Client) BulkUpdate(ctx context.Context, collection *mongo.Collection, ...) error
- func (client *Client) BulkUpdateItems(ctx context.Context, collection *mongo.Collection, ...) error
- func (client *Client) BulkUpsertItems(ctx context.Context, collection *mongo.Collection, ...) error
- func (client *Client) Count(ctx context.Context, collection *mongo.Collection, query interface{}, ...) (int64, error)
- func (client *Client) Delete(ctx context.Context, collection *mongo.Collection, selector interface{}, ...) error
- func (client *Client) DeleteById(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID, ...) error
- func (client *Client) ExecTx(ctx context.Context, f func(context.Context)) error
- func (client *Client) FindById(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID, ...) error
- func (client *Client) FindByIds(ctx context.Context, collection *mongo.Collection, ids []primitive.ObjectID, ...) error
- func (client *Client) FindByModel(ctx context.Context, collection *mongo.Collection, model FindModel, ...) error
- func (client *Client) FindOneAndUpdate(ctx context.Context, collection *mongo.Collection, ...) error
- func (client *Client) FindOneByModel(ctx context.Context, collection *mongo.Collection, model FindModel, ...) error
- func (client *Client) Insert(ctx context.Context, collection *mongo.Collection, data interface{}, ...) error
- func (client *Client) Update(ctx context.Context, collection *mongo.Collection, selector interface{}, ...) error
- func (client *Client) UpdateById(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID, ...) error
- func (client *Client) UpdateByIds(ctx context.Context, collection *mongo.Collection, ids []primitive.ObjectID, ...) error
- func (client *Client) Upsert(ctx context.Context, collection *mongo.Collection, selector interface{}, ...) error
- type CollectionOp
- func (c *CollectionOp) Aggregate(ctx context.Context, pipeline interface{}, result interface{}) error
- func (c *CollectionOp) BatchInsert(ctx context.Context, data []interface{}) error
- func (c *CollectionOp) BulkUpdateItems(ctx context.Context, bulkUpdateItems []*BulkUpdateItem, ...) error
- func (c *CollectionOp) BulkUpsertItem(ctx context.Context, bulkUpertItems []*BulkUpsertItem, ...) error
- func (c *CollectionOp) Count(ctx context.Context, query interface{}) (int64, error)
- func (c *CollectionOp) Delete(ctx context.Context, selector interface{}) error
- func (c *CollectionOp) DeleteById(ctx context.Context, id primitive.ObjectID) error
- func (c *CollectionOp) Find(ctx context.Context, model FindModel, opts ...*options.FindOptions) error
- func (c *CollectionOp) FindById(ctx context.Context, id primitive.ObjectID, result interface{}) error
- func (c *CollectionOp) FindOne(ctx context.Context, model FindModel, opts ...*options.FindOneOptions) error
- func (c *CollectionOp) FindOneAndUpdate(ctx context.Context, result interface{}, query interface{}, ...) error
- func (c *CollectionOp) Insert(ctx context.Context, data interface{}) error
- func (c *CollectionOp) Update(ctx context.Context, selector interface{}, updateOp interface{}) error
- func (c *CollectionOp) UpdateById(ctx context.Context, id primitive.ObjectID, updateOp interface{}) error
- func (c *CollectionOp) Upsert(ctx context.Context, selector interface{}, updateOp bson.M, ...) error
- type CompCollectionOp
- type FindModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitClients ¶
func InitClients()
func StringsToBsonId ¶
Types ¶
type BulkUpsertItem ¶ added in v1.0.17
type Client ¶
func (*Client) Aggregate ¶
func (client *Client) Aggregate(ctx context.Context, collection *mongo.Collection, pipeline interface{}, result interface{}, opts ...*options.AggregateOptions) error
func (*Client) BatchInsert ¶
func (client *Client) BatchInsert(ctx context.Context, collection *mongo.Collection, data []interface{}, opts ...*options.InsertManyOptions) error
func (*Client) BulkUpdate ¶
func (client *Client) BulkUpdate(ctx context.Context, collection *mongo.Collection, bulkModels []mongo.WriteModel, opts ...*options.BulkWriteOptions) error
func (*Client) BulkUpdateItems ¶
func (client *Client) BulkUpdateItems(ctx context.Context, collection *mongo.Collection, bulkUpdateItems []*BulkUpdateItem, opts ...*options.BulkWriteOptions) error
func (*Client) BulkUpsertItems ¶
func (client *Client) BulkUpsertItems(ctx context.Context, collection *mongo.Collection, bulkUpsertItems []*BulkUpsertItem, opts ...*options.BulkWriteOptions) error
The replacement parameter must be a document that will be used to replace the selected document. It cannot be nil and cannot contain any update operators
func (*Client) Count ¶
func (client *Client) Count(ctx context.Context, collection *mongo.Collection, query interface{}, opts ...*options.CountOptions) (int64, error)
func (*Client) Delete ¶
func (client *Client) Delete(ctx context.Context, collection *mongo.Collection, selector interface{}, opts ...*options.DeleteOptions) error
func (*Client) DeleteById ¶
func (client *Client) DeleteById(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID, opts ...*options.DeleteOptions) error
func (*Client) FindById ¶
func (client *Client) FindById(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID, result interface{}, opts ...*options.FindOneOptions) error
read
func (*Client) FindByIds ¶
func (client *Client) FindByIds(ctx context.Context, collection *mongo.Collection, ids []primitive.ObjectID, result interface{}, opts ...*options.FindOptions) error
func (*Client) FindByModel ¶
func (client *Client) FindByModel(ctx context.Context, collection *mongo.Collection, model FindModel, opts ...*options.FindOptions) error
func (*Client) FindOneAndUpdate ¶
func (*Client) FindOneByModel ¶
func (client *Client) FindOneByModel(ctx context.Context, collection *mongo.Collection, model FindModel, opts ...*options.FindOneOptions) error
func (*Client) Insert ¶
func (client *Client) Insert(ctx context.Context, collection *mongo.Collection, data interface{}, opts ...*options.InsertOneOptions) error
write
func (*Client) Update ¶
func (client *Client) Update(ctx context.Context, collection *mongo.Collection, selector interface{}, update interface{}, opts ...*options.UpdateOptions) error
func (*Client) UpdateById ¶
func (client *Client) UpdateById(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID, update interface{}, opts ...*options.UpdateOptions) error
func (*Client) UpdateByIds ¶
func (client *Client) UpdateByIds(ctx context.Context, collection *mongo.Collection, ids []primitive.ObjectID, update interface{}, opts ...*options.UpdateOptions) error
func (*Client) Upsert ¶
func (client *Client) Upsert(ctx context.Context, collection *mongo.Collection, selector interface{}, update interface{}, opts ...*options.UpdateOptions) error
type CollectionOp ¶
type CollectionOp struct {
// contains filtered or unexported fields
}
集合操作类
func NewMgoCollection ¶
func NewMgoCollection(client *Client, dbName, collectionName string, dbOpts []*options.DatabaseOptions, cOpts []*options.CollectionOptions) *CollectionOp
func (*CollectionOp) Aggregate ¶
func (c *CollectionOp) Aggregate(ctx context.Context, pipeline interface{}, result interface{}) error
func (*CollectionOp) BatchInsert ¶
func (c *CollectionOp) BatchInsert(ctx context.Context, data []interface{}) error
func (*CollectionOp) BulkUpdateItems ¶ added in v1.0.17
func (c *CollectionOp) BulkUpdateItems(ctx context.Context, bulkUpdateItems []*BulkUpdateItem, opts ...*options.BulkWriteOptions) error
func (*CollectionOp) BulkUpsertItem ¶ added in v1.0.17
func (c *CollectionOp) BulkUpsertItem(ctx context.Context, bulkUpertItems []*BulkUpsertItem, opts ...*options.BulkWriteOptions) error
func (*CollectionOp) Count ¶
func (c *CollectionOp) Count(ctx context.Context, query interface{}) (int64, error)
func (*CollectionOp) Delete ¶
func (c *CollectionOp) Delete(ctx context.Context, selector interface{}) error
func (*CollectionOp) DeleteById ¶
func (*CollectionOp) Find ¶
func (c *CollectionOp) Find(ctx context.Context, model FindModel, opts ...*options.FindOptions) error
func (*CollectionOp) FindOne ¶
func (c *CollectionOp) FindOne(ctx context.Context, model FindModel, opts ...*options.FindOneOptions) error
func (*CollectionOp) FindOneAndUpdate ¶
func (*CollectionOp) Insert ¶
func (c *CollectionOp) Insert(ctx context.Context, data interface{}) error
func (*CollectionOp) Update ¶
func (c *CollectionOp) Update(ctx context.Context, selector interface{}, updateOp interface{}) error
func (*CollectionOp) UpdateById ¶
type CompCollectionOp ¶
type CompCollectionOp struct { *CollectionOp //全局配置 Primary *CollectionOp //强制读主库 Slave *CollectionOp //优先读从库 }
复合集合操作类
func NewCompCollectionOp ¶
func NewCompCollectionOp(client *Client, dbName, collectionName string) *CompCollectionOp
Click to show internal directories.
Click to hide internal directories.