Documentation ¶
Index ¶
- Variables
- func GetMongoClient(opts ...ClientOption) (c *mongo.Client, err error)
- func GetMongoDb(dbName string, opts ...DbOption) (db *mongo.Database)
- func RunTransaction(fn func(mongo.SessionContext) error) (err error)
- func RunTransactionWithContext(ctx context.Context, fn func(mongo.SessionContext) error) (err error)
- type ClientOption
- func WithAuthMechanism(value string) ClientOption
- func WithAuthSource(value string) ClientOption
- func WithContext(ctx context.Context) ClientOption
- func WithDb(value string) ClientOption
- func WithHost(value string) ClientOption
- func WithHosts(value []string) ClientOption
- func WithPassword(value string) ClientOption
- func WithPort(value int) ClientOption
- func WithUri(value string) ClientOption
- func WithUsername(value string) ClientOption
- type ClientOptions
- 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) GetCollection() (c *mongo.Collection)
- 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 DbOption
- type DbOptions
- type FindOptions
- type FindResult
- func (fr *FindResult) All(val interface{}) (err error)
- func (fr *FindResult) GetCol() (col *Col)
- func (fr *FindResult) GetCursor() (cur *mongo.Cursor)
- func (fr *FindResult) GetError() (err error)
- func (fr *FindResult) GetSingleResult() (res *mongo.SingleResult)
- func (fr *FindResult) One(val interface{}) (err error)
- type FindResultInterface
Constants ¶
This section is empty.
Variables ¶
View Source
var AppName = "crawlab-db"
Functions ¶
func GetMongoClient ¶
func GetMongoClient(opts ...ClientOption) (c *mongo.Client, err error)
func RunTransaction ¶
func RunTransaction(fn func(mongo.SessionContext) error) (err error)
Types ¶
type ClientOption ¶
type ClientOption func(options *ClientOptions)
func WithAuthMechanism ¶
func WithAuthMechanism(value string) ClientOption
func WithAuthSource ¶
func WithAuthSource(value string) ClientOption
func WithContext ¶
func WithContext(ctx context.Context) ClientOption
func WithDb ¶
func WithDb(value string) ClientOption
func WithHost ¶
func WithHost(value string) ClientOption
func WithHosts ¶
func WithHosts(value []string) ClientOption
func WithPassword ¶
func WithPassword(value string) ClientOption
func WithPort ¶
func WithPort(value int) ClientOption
func WithUri ¶
func WithUri(value string) ClientOption
func WithUsername ¶
func WithUsername(value string) ClientOption
type ClientOptions ¶
type Col ¶
type Col struct {
// contains filtered or unexported fields
}
func GetMongoCol ¶
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) GetCollection ¶
func (col *Col) GetCollection() (c *mongo.Collection)
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) GetCollection() (c *mongo.Collection) }
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) GetCol ¶
func (fr *FindResult) GetCol() (col *Col)
func (*FindResult) GetCursor ¶
func (fr *FindResult) GetCursor() (cur *mongo.Cursor)
func (*FindResult) GetError ¶
func (fr *FindResult) GetError() (err error)
func (*FindResult) GetSingleResult ¶
func (fr *FindResult) GetSingleResult() (res *mongo.SingleResult)
func (*FindResult) One ¶
func (fr *FindResult) One(val interface{}) (err error)
type FindResultInterface ¶
Click to show internal directories.
Click to hide internal directories.