Documentation ¶
Index ¶
- Variables
- func CreateIndex(indexes []Index)
- func IsDuplicateKey(err error) bool
- func NewMongoClient(ctx context.Context, opts ...*options.ClientOptions) (*mongo.Client, error)
- func NewMongoClientByURI(ctx context.Context, uri string) (*mongo.Client, error)
- func URIToHosts(uri string) []string
- type CollStatsResp
- type Command
- type Config
- type Conn
- type DBStatsResp
- type DataBaseInterface
- type Database
- func (db *Database) Exists(ctx context.Context, collection string, filter interface{}) (bool, error)
- func (db *Database) Find(ctx context.Context, collection string, filter bson.M, docs interface{}, ...) error
- func (db *Database) FindCount(ctx context.Context, collection string, filter interface{}, docs interface{}, ...) (int64, error)
- func (db *Database) FindOne(ctx context.Context, collection string, filter interface{}, doc interface{}, ...) (bool, error)
- func (db *Database) ListCollectionNames(ctx context.Context, prefix ...string) ([]string, error)
- func (db *Database) Transaction(ctx context.Context, tx func(sessCtx SessionContext) error) error
- func (db *Database) UpsertCollectionIndexMany(indexMany ...[]Index) error
- type Groups
- type HostInfoResp
- type Index
- type SessionContext
- type ShardCollection
- func (sc ShardCollection) CollNameByStartEnd(bucket string, start, end int64) []string
- func (sc ShardCollection) CollNameDate(collName string) (time.Time, error)
- func (sc ShardCollection) DaySpan() map[int]int
- func (sc ShardCollection) DecodeCollName(collName string) (prefix, bucket string, year int, month time.Month, span int, err error)
- func (sc ShardCollection) EncodeCollName(bucket string, timestamp int64) string
- func (sc ShardCollection) SepTime(collName string) (t time.Time, err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotMatched = errors.New("not matched") ErrInstanceNotFound = errors.New("mongodb instance db not found") ErrNoDocuments = mongo.ErrNoDocuments )
View Source
var Indexes []Index
Functions ¶
func CreateIndex ¶
func CreateIndex(indexes []Index)
CreateIndex add indexes to Indexes, waiting create
func IsDuplicateKey ¶
func NewMongoClient ¶
NewMongoClient client and ping
func NewMongoClientByURI ¶
NewMongoClientByURI uri = mongo://...
Types ¶
type CollStatsResp ¶ added in v0.1.1
type CollStatsResp struct { Ok int `json:"ok"` Ns string `json:"ns"` Size int64 `json:"size"` Count int64 `json:"count"` AvgObjSize int64 `json:"avgObjSize"` StorageSize int64 `json:"storageSize"` Capped bool `json:"capped"` TotalIndexSize int64 `json:"totalIndexSize"` IndexSizes map[string]int64 `json:"indexSizes"` }
type Command ¶ added in v0.1.1
type Command struct {
// contains filtered or unexported fields
}
func NewCommand ¶ added in v0.1.1
type DBStatsResp ¶ added in v0.1.1
type DataBaseInterface ¶
type DataBaseInterface interface { Exists(ctx context.Context, collection string, filter interface{}) (bool, error) FindOne(ctx context.Context, collection string, filter interface{}, doc interface{}, opt ...*options.FindOneOptions) (bool, error) Find(ctx context.Context, collection string, filter bson.M, docs interface{}, opt ...*options.FindOptions) error FindCount(ctx context.Context, collection string, filter interface{}, docs interface{}, findOpt *options.FindOptions, countOpt *options.CountOptions) (int64, error) ListCollectionNames(ctx context.Context, prefix ...string) ([]string, error) UpsertCollectionIndexMany(indexMany ...[]Index) error Transaction(ctx context.Context, tx func(sessCtx SessionContext) error) error Client() *mongo.Client Name() string Collection(name string, opts ...*options.CollectionOptions) *mongo.Collection Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error) RunCommand(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) *mongo.SingleResult RunCommandCursor(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) (*mongo.Cursor, error) Drop(ctx context.Context) error ListCollectionSpecifications(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) ([]*mongo.CollectionSpecification, error) ListCollections(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) (*mongo.Cursor, error) ReadConcern() *readconcern.ReadConcern ReadPreference() *readpref.ReadPref WriteConcern() *writeconcern.WriteConcern Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error) CreateCollection(ctx context.Context, name string, opts ...*options.CreateCollectionOptions) error CreateView(ctx context.Context, viewName, viewOn string, pipeline interface{}, opts ...*options.CreateViewOptions) error }
type Database ¶
Database packaging some method, shortcut
func (*Database) FindCount ¶
func (db *Database) FindCount(ctx context.Context, collection string, filter interface{}, docs interface{}, findOpt *options.FindOptions, countOpt *options.CountOptions) (int64, error)
func (*Database) ListCollectionNames ¶
func (*Database) Transaction ¶ added in v0.1.2
Transaction Only supports single db
func (*Database) UpsertCollectionIndexMany ¶
type Groups ¶
type Groups struct { Config Config // contains filtered or unexported fields }
Groups Mongodb instance groups
func (*Groups) Disconnect ¶
type HostInfoResp ¶ added in v0.1.1
type Index ¶
type SessionContext ¶ added in v0.1.2
type SessionContext mongo.SessionContext
type ShardCollection ¶
type ShardCollection struct { Prefix string Sep string // sep tag // contains filtered or unexported fields }
ShardCollection sharding collection name
func NewShardCollection ¶
func NewShardCollection(prefix string, day int) ShardCollection
prefix collection name prefix day>=31 | day<=0 month, day = x, span = x
func (ShardCollection) CollNameByStartEnd ¶
func (sc ShardCollection) CollNameByStartEnd(bucket string, start, end int64) []string
CollNameByStartEnd find collection names by bucket,start,end
func (ShardCollection) CollNameDate ¶
func (sc ShardCollection) CollNameDate(collName string) (time.Time, error)
func (ShardCollection) DaySpan ¶
func (sc ShardCollection) DaySpan() map[int]int
func (ShardCollection) DecodeCollName ¶
func (ShardCollection) EncodeCollName ¶
func (sc ShardCollection) EncodeCollName(bucket string, timestamp int64) string
Click to show internal directories.
Click to hide internal directories.