db

package
v0.0.0-...-bc78c8b Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASSETS_COLLECTION                       = "assets"
	EVENT_LOGS_COLLECTION                   = "eventlogs"
	NOTIFICATIONS_COLLECTION                = "notifications"
	ACCOUNTS_COLLECTION                     = "accounts"
	BENCHMARKS_COLLECTION                   = "benchmarks"
	ASSETS_PRICES_COLLECTION                = "assetsprices"
	APPLICATION_EXECUTION_STATES_COLLECTION = "applicationExecutionStates"
	APPLICATIONS_COLLECTION                 = "applications"
	DCA_JOBS_COLLECTION                     = "dcaJobs"
	DCA_ASSETS_COLLECTION                   = "dcaAssets"
)

Variables

This section is empty.

Functions

func BatchBulkCreate

func BatchBulkCreate(BulkCreate func(*[]bson.M) error, documents *[]bson.M, limit int) error

func ConnectDB

func ConnectDB(mongoUrl string) (*mongo.Client, error)

func NewMongoQueryContext

func NewMongoQueryContext() (context.Context, context.CancelFunc)

Types

type Repository

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

Repository is a generic mongo service to used by other repositories

func NewRepository

func NewRepository(c *mongo.Collection) *Repository

NewRepository returns an instance of Repository

func (*Repository) Aggregate

func (r *Repository) Aggregate(documents interface{}, pipelineOptions mongo.Pipeline) error

Aggregate returns rows aggregated

func (*Repository) BulkCreate

func (r *Repository) BulkCreate(documents *[]bson.M) error

BulkCreate creates multiple documents

func (*Repository) BulkDelete

func (r *Repository) BulkDelete(filter bson.M) error

BulkDelete deletes multiple documents

func (*Repository) BulkUpdate

func (r *Repository) BulkUpdate(filter bson.M, update bson.M) error

BulkUpdate updates multiple documents

func (*Repository) BulkUpsert

func (r *Repository) BulkUpsert(documents []bson.M) error

BulkUpsert creates multiple documents if there are no documents with the same data

func (*Repository) DeleteByID

func (r *Repository) DeleteByID(id string) error

DeleteByID delete one document by ID

func (*Repository) FindAll

func (r *Repository) FindAll(documents interface{}, filter interface{}, opts *options.FindOptions) error

FindAll returns rows that match criteria

func (*Repository) FindOne

func (r *Repository) FindOne(document interface{}, filter interface{}, opts *options.FindOneOptions) error

FindOne returns one row that match criteria

func (*Repository) InsertOne

func (r *Repository) InsertOne(document interface{}) error

InsertOne creates one document

func (*Repository) UpdateOne

func (r *Repository) UpdateOne(filter interface{}, update interface{}) error

UpdateOne updates one document found with match criteria

Jump to

Keyboard shortcuts

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