database

package
v0.0.0-...-907143c Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExists = errors.New("element already exists")
View Source
var ErrNotFound = errors.New("element not found in collection")

Functions

func Set

func Set(d interface{}) bson.M

func SetOrdered

func SetOrdered(data ...interface{}) bson.D

Types

type Collection

type Collection string

type Database

type Database interface {
	FindOne(coll Collection, filter interface{}, res interface{}) error
	FindOneById(coll Collection, id string, res interface{}) error
	FindOneSorted(coll Collection, filter bson.M, sort bson.M, res interface{}) error
	FindMany(coll Collection, filter bson.M, each func(c Decodable) error) error
	FindManyWithOptions(coll Collection, filter bson.M, each func(c Decodable) error, sort bson.M, limit int) error
	ListPaginated(coll Collection, perPage int, page int, p *sdk.Pagination, each func(c Decodable) error) error

	UpdateProvided(coll Collection, provider string, updates map[string]interface{}) error
	UpdateMany(coll Collection, filters map[string]interface{}, updates map[string]interface{}) error
	UpdateOne(coll Collection, filter bson.M, createIfMissing bool, update interface{}, res interface{}) error
	UpdateOneById(coll Collection, id string, createIfMissing bool, update interface{}, res interface{}) error

	InsertOne(coll Collection, existsFilter interface{}, data interface{}) error

	DeleteOne(coll Collection, filter bson.M) error
	DeleteOneById(coll Collection, id string) error

	EnsureIndex(coll Collection, model mongo.IndexModel) error
}

func NewMongoDB

func NewMongoDB(l MongoLogin) (Database, error)

type Decodable

type Decodable interface {
	Decode(interface{}) error
}

type DecodableFunc

type DecodableFunc func(target interface{}) error

func (DecodableFunc) Decode

func (f DecodableFunc) Decode(dec interface{}) error

type ErrMongoQueryFailed

type ErrMongoQueryFailed struct {
	Err error
}

func (*ErrMongoQueryFailed) Error

func (r *ErrMongoQueryFailed) Error() string

func (*ErrMongoQueryFailed) Is

func (r *ErrMongoQueryFailed) Is(target error) bool

func (*ErrMongoQueryFailed) Unwrap

func (r *ErrMongoQueryFailed) Unwrap() error

type MongoLogin

type MongoLogin struct {
	Uri string
	DB  string
}

Jump to

Keyboard shortcuts

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