mongodb

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EQ     = "$eq"
	NE     = "$ne"
	GT     = "$gt"
	GE     = "$gte"
	LT     = "$lt"
	LE     = "$lte"
	REGEX  = "$regex"
	EXISTS = "$exists"
	IN     = "$in"
	OR     = "$or"
	AND    = "$and"
	SET    = "$set"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type A

type A = bson.A

type Config

type Config struct {
	Database string `yaml:"database"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`

	Hosts []string `yaml:"hosts"`
}

func (*Config) Repair

func (c *Config) Repair()

type Conn

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

func Connect

func Connect(ctx context.Context, conf Config) (*Conn, error)

func (*Conn) Close

func (conn *Conn) Close(ctx Context) error

func (*Conn) CountDocuments

func (conn *Conn) CountDocuments(ctx Context, collection string, filter M) (int64, error)

func (*Conn) CreateCollection

func (conn *Conn) CreateCollection(ctx Context, collection string, opts ...*options.CreateCollectionOptions) error

func (*Conn) CreateIndexes

func (conn *Conn) CreateIndexes(ctx Context, collection string, opts []mongo.IndexModel) error

func (*Conn) Database

func (conn *Conn) Database() *mongo.Database

func (*Conn) DeleteByID

func (conn *Conn) DeleteByID(ctx Context, collection string, id PK) error

func (*Conn) DeleteMany

func (conn *Conn) DeleteMany(ctx Context, collection string, filter M) error

func (*Conn) DeleteOne

func (conn *Conn) DeleteOne(ctx Context, collection string, filter M) error

func (*Conn) Exists

func (conn *Conn) Exists(ctx Context, collection string, filter M) (ok bool, err error)

func (*Conn) FindAll

func (conn *Conn) FindAll(ctx Context, collection string, dst interface{}, filter M, opts ...*options.FindOptions) error

func (*Conn) FindByID

func (conn *Conn) FindByID(ctx Context, collection string, id PK, dst interface{}) (ok bool, err error)

func (*Conn) FindOne

func (conn *Conn) FindOne(ctx Context, collection string, filter M, dst interface{}, opts ...*options.FindOneOptions) (ok bool, err error)

func (*Conn) InsertOne

func (conn *Conn) InsertOne(ctx Context, collection string, document interface{}, returnID *PK) error

func (*Conn) Migrate

func (conn *Conn) Migrate(ctx Context, migrations map[int]Migration) error

func (*Conn) MigrateTo

func (conn *Conn) MigrateTo(ctx Context, migrations map[int]Migration, targetNumber int) error

func (*Conn) UpdateByID

func (conn *Conn) UpdateByID(ctx Context, collection string, id PK, update interface{}) error

func (*Conn) UpdateMany

func (conn *Conn) UpdateMany(ctx Context, collection string, filter M, update interface{}) error

func (*Conn) UpdateOne

func (conn *Conn) UpdateOne(ctx Context, collection string, filter M, update interface{}) error

type Context

type Context = context.Context

type M

type M = bson.M

type Migration

type Migration struct {
	Forward func(*Conn) error
	Reverse func(*Conn) error
}

type PK

type PK = string // string primary key

Jump to

Keyboard shortcuts

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