Documentation
¶
Index ¶
- Variables
- func NewGlobalHelper(opts ...Option) error
- type Auth
- type Client
- type CollClient
- type CursorClient
- type DBClient
- type Helper
- func (h *Helper) Close()
- func (h *Helper) DeleteAll(db, coll string, filter interface{}) error
- func (h *Helper) DeleteOne(db, coll string, filter interface{}) error
- func (h *Helper) Get(db, coll string, filter bson.M) (*mongo.SingleResult, error)
- func (h *Helper) GetAllCollections(db string) ([]string, error)
- func (h *Helper) GetCount(db, coll string, filter bson.M) (int64, error)
- func (h *Helper) GetQueryCursor(db, coll string, query bson.M, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (h *Helper) Insert(db, coll string, data interface{}) error
- func (h *Helper) InsertMany(db, coll string, data []interface{}) error
- func (h *Helper) NewCollCli(db, coll string) (CollClient, error)
- func (h *Helper) NewDBCli(db string) (DBClient, error)
- func (h *Helper) NewTxnCli() (TxnClient, error)
- func (h *Helper) SetMongoClient() error
- func (h *Helper) UpdateMany(db, coll string, filter interface{}, data interface{}) error
- func (h *Helper) UpdateOne(db, coll string, filter interface{}, data interface{}, ...) error
- type Option
- func AuthEnable(enable bool) Option
- func AuthPassword(password string) Option
- func AuthSource(source string) Option
- func AuthUsername(username string) Option
- func Collection(collection string) Option
- func Collections(collections map[string]string) Option
- func Connect(connect string) Option
- func Database(database string) Option
- func Databases(databases map[string]string) Option
- func ReplicaSet(replicaSet string) Option
- func Uri(uri string) Option
- type Options
- type TxnClient
Constants ¶
This section is empty.
Variables ¶
View Source
var (
CreateRecordIfNotExist = options.Update().SetUpsert(true)
)
Functions ¶
func NewGlobalHelper ¶
Types ¶
type CollClient ¶
type CollClient interface { Find(context.Context, interface{}, ...*options.FindOptions) (*mongo.Cursor, error) FindOne(context.Context, interface{}, ...*options.FindOneOptions) *mongo.SingleResult FindOneAndUpdate(context.Context, interface{}, interface{}, ...*options.FindOneAndUpdateOptions) *mongo.SingleResult FindOneAndDelete(context.Context, interface{}, ...*options.FindOneAndDeleteOptions) *mongo.SingleResult InsertOne(context.Context, interface{}, ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) InsertMany(context.Context, []interface{}, ...*options.InsertManyOptions) (*mongo.InsertManyResult, error) DeleteOne(context.Context, interface{}, ...*options.DeleteOptions) (*mongo.DeleteResult, error) DeleteMany(context.Context, interface{}, ...*options.DeleteOptions) (*mongo.DeleteResult, error) UpdateOne(context.Context, interface{}, interface{}, ...*options.UpdateOptions) (*mongo.UpdateResult, error) UpdateMany(context.Context, interface{}, interface{}, ...*options.UpdateOptions) (*mongo.UpdateResult, error) CountDocuments(context.Context, interface{}, ...*options.CountOptions) (int64, error) }
type CursorClient ¶
type DBClient ¶
type DBClient interface { Collection(string, ...*options.CollectionOptions) *mongo.Collection ListCollectionNames(context.Context, interface{}, ...*options.ListCollectionsOptions) ([]string, error) }
type Helper ¶
func GetGlobalHelper ¶
func GetGlobalHelper() *Helper
func (*Helper) GetQueryCursor ¶
func (*Helper) InsertMany ¶
func (*Helper) NewCollCli ¶
func (h *Helper) NewCollCli(db, coll string) (CollClient, error)
func (*Helper) SetMongoClient ¶
func (*Helper) UpdateMany ¶
type Option ¶
type Option func(*Options)
func AuthEnable ¶
func AuthPassword ¶
func AuthSource ¶
func AuthUsername ¶
func Collection ¶
func Collections ¶
func ReplicaSet ¶
type Options ¶
type Options struct { Uri string `json:"uri" yaml:"uri"` Auth `json:"auth" yaml:"auth"` ReplicaSet string `json:"replicaSet" yaml:"replicaSet"` Connect string `json:"connect" yaml:"connect"` Database string `json:"database" yaml:"database"` Collection string `json:"collection" yaml:"collection"` Databases map[string]string `json:"databases" yaml:"databases"` Collections map[string]string `json:"collections" yaml:"collections"` }
var (
Opts *Options
)
Click to show internal directories.
Click to hide internal directories.