mongo

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryWhereCondition

func QueryWhereCondition(pointerOnEntity interface{}) bson.M

Types

type Collection

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

func (Collection) DeleteOne

func (c Collection) DeleteOne(ctx context.Context, filter interface{}) (int64, error)

func (Collection) Find

func (c Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (ICursor, error)

func (Collection) FindOne

func (c Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) ISingleResult

func (Collection) InsertOne

func (c Collection) InsertOne(ctx context.Context, document interface{}) (interface{}, error)

func (Collection) UpdateOne

func (c Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}) (interface{}, error)

type Config

type Config struct {
	DSN    string
	DBName string
}

type Cursor

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

func (Cursor) Decode

func (c Cursor) Decode(val interface{}) error

func (Cursor) Next

func (c Cursor) Next(ctx context.Context) bool

type DB

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

func (*DB) Close

func (d *DB) Close(ctx context.Context) error

func (DB) Collection

func (b DB) Collection(name string, opts ...*options.CollectionOptions) ICollection

type ICollection

type ICollection interface {
	FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) ISingleResult
	Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (ICursor, error)
	InsertOne(ctx context.Context, document interface{}) (interface{}, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{}) (interface{}, error)
	DeleteOne(ctx context.Context, filter interface{}) (int64, error)
}

type ICursor

type ICursor interface {
	Next(ctx context.Context) bool
	Decode(val interface{}) error
}

type IDB

type IDB interface {
	Collection(name string, opts ...*options.CollectionOptions) ICollection
	Close(ctx context.Context) error
}

IDB is the interface for a DB connection

func New

func New(conf Config) (IDB, error)

New creates a new DB connection

type ISingleResult

type ISingleResult interface {
	Decode(val interface{}) error
}

type SingleResult

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

func (SingleResult) Decode

func (r SingleResult) Decode(val interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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