mongo

package
v0.0.0-...-532f4bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorDuplicateKey

type ErrorDuplicateKey struct {
}

func (*ErrorDuplicateKey) Error

func (e *ErrorDuplicateKey) Error() string

type HxMongo

type HxMongo struct {
	// contains filtered or unexported fields
}

func ConnectMongoDb

func ConnectMongoDb(mongoURI string, maxPoolSize uint64) (*HxMongo, error)

ConnectMongoDb https://docs.mongodb.com/manual/reference/connection-string/

func (*HxMongo) Aggregate

func (cli *HxMongo) Aggregate(dbName string, collName string, pipeline interface{}) (*mongo.Cursor, error)

func (*HxMongo) Count

func (cli *HxMongo) Count(dbName string, collName string, filter interface{}, opts *options.CountOptions) (int64, error)

func (*HxMongo) CreateCollection

func (cli *HxMongo) CreateCollection(dbName, collName string) error

func (*HxMongo) CreateCollectionIndex

func (cli *HxMongo) CreateCollectionIndex(dbName, collName string, indexModels []mongo.IndexModel) ([]string, error)

func (*HxMongo) Delete

func (cli *HxMongo) Delete(dbName string, collName string, filter interface{}, bMany bool) (int64, error)

func (*HxMongo) DeleteCollection

func (cli *HxMongo) DeleteCollection(dbName, collName string) error

func (*HxMongo) Find

func (cli *HxMongo) Find(dbName string, collName string, filter interface{}, opts *options.FindOptions) (*mongo.Cursor, error)

func (*HxMongo) FindOne

func (cli *HxMongo) FindOne(dbName string, collName string, filter interface{}, opts *options.FindOneOptions) (*mongo.SingleResult, error)

func (*HxMongo) GetCollection

func (cli *HxMongo) GetCollection(dbName, collName string) *mongo.Collection

func (*HxMongo) GetCollectionNames

func (cli *HxMongo) GetCollectionNames(dbName string) ([]string, error)

func (*HxMongo) GetDatabase

func (cli *HxMongo) GetDatabase(dbName string) *mongo.Database

func (*HxMongo) HasCollection

func (cli *HxMongo) HasCollection(dbName, collName string) (bool, error)

func (*HxMongo) InsertMany

func (cli *HxMongo) InsertMany(dbName string, collName string, documents []interface{}) ([]interface{}, error)

func (*HxMongo) InsertOne

func (cli *HxMongo) InsertOne(dbName, collName string, document interface{}) (interface{}, error)

InsertOne 这种需要创建唯一索引

func (*HxMongo) Replace

func (cli *HxMongo) Replace(dbName string, collName string, filter interface{}, replacement interface{}) (interface{}, error)

func (*HxMongo) Transaction

func (cli *HxMongo) Transaction(ctx context.Context, fn func(mongo.SessionContext) error) error

func (*HxMongo) Update

func (cli *HxMongo) Update(dbName string, collName string, filter interface{}, update interface{}, bMany bool) (interface{}, int64, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL