db

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDbUniqueKeyError

func IsDbUniqueKeyError(err error) bool

IsDbUniqueKeyError retorna true si el error es de indice único

func NewDatabase

func NewDatabase(
	mongoUrl string,
	name string,
) (*mongo.Database, error)

NewDatabase the mongo database

Types

type Collection

type Collection interface {
	FindOne(ctx context.Context, filter interface{}, v interface{}) error

	InsertOne(ctx context.Context, document interface{}) (id interface{}, error error)

	UpdateOne(ctx context.Context, filter interface{}, update interface{}) (modified int64, error error)

	Find(ctx context.Context, filter interface{}) (cur Cursor, err error)
}

func NewCollection

func NewCollection(
	log log.LogRusEntry,
	database *mongo.Database,
	collectionName string,
	onError func(error),
	indexes ...string,
) (col Collection, err error)

type Cursor

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

func NewCursor

func NewCursor(cursor *mongo.Cursor) Cursor

Jump to

Keyboard shortcuts

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