Documentation ¶
Index ¶
- Variables
- func GetMongoClient() (c *mongo.Client, err error)
- func GetMongoDb(dbName string) (db *mongo.Database)
- func RunTransaction(fn func(mongo.SessionContext) error) (err error)
- type Col
- func (col *Col) Aggregate(pipeline mongo.Pipeline, opts *options.AggregateOptions) (fr *FindResult)
- func (col *Col) Count(query bson.M) (total int, err error)
- func (col *Col) CreateIndex(indexModel mongo.IndexModel) (err error)
- func (col *Col) CreateIndexes(indexModels []mongo.IndexModel) (err error)
- func (col *Col) Delete(query bson.M) (err error)
- func (col *Col) DeleteAllIndexes() (err error)
- func (col *Col) DeleteId(id primitive.ObjectID) (err error)
- func (col *Col) DeleteIndex(name string) (err error)
- func (col *Col) DeleteWithOptions(query bson.M, opts *options.DeleteOptions) (err error)
- func (col *Col) Find(query bson.M, opts *FindOptions) (fr *FindResult)
- func (col *Col) FindId(id primitive.ObjectID) (fr *FindResult)
- func (col *Col) GetContext() (ctx context.Context)
- func (col *Col) GetName() (name string)
- func (col *Col) Insert(doc interface{}) (id primitive.ObjectID, err error)
- func (col *Col) InsertMany(docs []interface{}) (ids []primitive.ObjectID, err error)
- func (col *Col) ListIndexes() (indexes []map[string]interface{}, err error)
- func (col *Col) MustCreateIndex(indexModel mongo.IndexModel)
- func (col *Col) MustCreateIndexes(indexModels []mongo.IndexModel)
- func (col *Col) Replace(query bson.M, doc interface{}) (err error)
- func (col *Col) ReplaceId(id primitive.ObjectID, doc interface{}) (err error)
- func (col *Col) ReplaceWithOptions(query bson.M, doc interface{}, opts *options.ReplaceOptions) (err error)
- func (col *Col) Update(query bson.M, update interface{}) (err error)
- func (col *Col) UpdateId(id primitive.ObjectID, update interface{}) (err error)
- func (col *Col) UpdateWithOptions(query bson.M, update interface{}, opts *options.UpdateOptions) (err error)
- type ColInterface
- type FindOptions
- type FindResult
- type FindResultInterface
Constants ¶
This section is empty.
Variables ¶
View Source
var AppName = "crawlab-db"
View Source
var Client *mongo.Client
Functions ¶
func GetMongoClient ¶ added in v0.1.1
func GetMongoDb ¶
func RunTransaction ¶
func RunTransaction(fn func(mongo.SessionContext) error) (err error)
Types ¶
type Col ¶
type Col struct {
// contains filtered or unexported fields
}
func GetMongoCol ¶
func GetMongoColWithDb ¶
func (*Col) Aggregate ¶
func (col *Col) Aggregate(pipeline mongo.Pipeline, opts *options.AggregateOptions) (fr *FindResult)
func (*Col) CreateIndex ¶
func (col *Col) CreateIndex(indexModel mongo.IndexModel) (err error)
func (*Col) CreateIndexes ¶
func (col *Col) CreateIndexes(indexModels []mongo.IndexModel) (err error)
func (*Col) DeleteAllIndexes ¶
func (*Col) DeleteIndex ¶
func (*Col) DeleteWithOptions ¶
func (*Col) Find ¶
func (col *Col) Find(query bson.M, opts *FindOptions) (fr *FindResult)
func (*Col) GetContext ¶
func (*Col) InsertMany ¶
func (*Col) ListIndexes ¶
func (*Col) MustCreateIndex ¶
func (col *Col) MustCreateIndex(indexModel mongo.IndexModel)
func (*Col) MustCreateIndexes ¶
func (col *Col) MustCreateIndexes(indexModels []mongo.IndexModel)
func (*Col) ReplaceWithOptions ¶
func (*Col) UpdateWithOptions ¶
type ColInterface ¶
type ColInterface interface { Insert(doc interface{}) (id primitive.ObjectID, err error) InsertMany(docs []interface{}) (ids []primitive.ObjectID, err error) UpdateId(id primitive.ObjectID, update interface{}) (err error) Update(query bson.M, update interface{}) (err error) UpdateWithOptions(query bson.M, update interface{}, opts *options.UpdateOptions) (err error) ReplaceId(id primitive.ObjectID, doc interface{}) (err error) Replace(query bson.M, doc interface{}) (err error) ReplaceWithOptions(query bson.M, doc interface{}, opts *options.ReplaceOptions) (err error) DeleteId(id primitive.ObjectID) (err error) Delete(query bson.M) (err error) DeleteWithOptions(query bson.M, opts *options.DeleteOptions) (err error) Find(query bson.M, opts *FindOptions) (fr *FindResult) FindId(id primitive.ObjectID) (fr *FindResult) Count(query bson.M) (total int, err error) Aggregate(pipeline mongo.Pipeline, opts *options.AggregateOptions) (fr *FindResult) CreateIndex(indexModel mongo.IndexModel) (err error) CreateIndexes(indexModels []mongo.IndexModel) (err error) MustCreateIndex(indexModel mongo.IndexModel) MustCreateIndexes(indexModels []mongo.IndexModel) DeleteIndex(name string) (err error) DeleteAllIndexes() (err error) ListIndexes() (indexes []map[string]interface{}, err error) GetContext() (ctx context.Context) GetName() (name string) }
type FindResult ¶
type FindResult struct {
// contains filtered or unexported fields
}
func NewFindResult ¶
func NewFindResult() (fr *FindResult)
func NewFindResultWithError ¶
func NewFindResultWithError(err error) (fr *FindResult)
func (*FindResult) All ¶
func (fr *FindResult) All(val interface{}) (err error)
func (*FindResult) One ¶
func (fr *FindResult) One(val interface{}) (err error)
type FindResultInterface ¶
Click to show internal directories.
Click to hide internal directories.