mongodb

package
v0.0.0-...-4eb781d Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrorCodeDuplicateKey = 11000
)

Variables

This section is empty.

Functions

func HasErrorCode

func HasErrorCode(err error, code int) bool

Types

type Collection

type Collection struct {
	*mongo.Collection
}

func (Collection) DistinctString

func (c Collection) DistinctString(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]string, error)

func (Collection) FindAll

func (c Collection) FindAll(ctx context.Context, filter, results interface{}, opts ...*options.FindOptions) (err error)

func (Collection) SetupIndexes

func (c Collection) SetupIndexes(models []mongo.IndexModel) (err error)

type Database

type Database struct {
	*mongo.Database
}

func Connect

func Connect(ctx context.Context, opts *options.ClientOptions, dbName string) (db *Database, err error)

func (Database) Collection

func (d Database) Collection(name string, opts ...*options.CollectionOptions) *Collection

func (*Database) DoTx

func (db *Database) DoTx(ctx context.Context, fn func(ctx mongo.SessionContext) error) error

func (*Database) DoTxWithOptions

func (db *Database) DoTxWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(ctx mongo.SessionContext) error) error

func (Database) SetupSchemas

func (d Database) SetupSchemas(ctx context.Context, fs fs.FS, collectionNames []string) error

Jump to

Keyboard shortcuts

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