mongo

package
v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDB

func ConnectToDB() db.Connection

ConnectToDB connects to a mongodb database based on a shell variable ($MONGODB_URI)

Types

type Connection

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

Connection is a connection to a mongo database

func (*Connection) Count

func (c *Connection) Count(entry db.Entry, filter bson.M) (uint64, error)

Count counts documents in a collection

func (*Connection) DeleteByID

func (c *Connection) DeleteByID(e db.Entry, ids ...primitive.ObjectID) error

DeleteByID deletes an entry by its id

func (*Connection) Find

func (c *Connection) Find(e db.Entry, results any, filter bson.M, optionalOpts ...db.FindOptions) error

Find finds entries based on the filter

func (*Connection) FindOne

func (c *Connection) FindOne(e db.Entry, filter bson.M, optionalOpts ...db.FindOptions) error

FindOne finds a single entry based on the filter

func (*Connection) GetDB

func (c *Connection) GetDB() *mongo.Database

GetDB returns the underlying mongo database connection

func (*Connection) Insert

func (c *Connection) Insert(e ...db.Entry) error

Insert inserts an entry into the database

func (*Connection) RegisterEntries

func (c *Connection) RegisterEntries(entries ...db.Entry)

RegisterEntries creates a collection for every entry

func (*Connection) UpdateByID

func (c *Connection) UpdateByID(e db.Entry) error

UpdateByID updates an entry by its id

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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