Documentation ¶
Index ¶
- func ConnectToDB() db.Connection
- type Connection
- func (c *Connection) Count(entry db.Entry, filter bson.M) (uint64, error)
- func (c *Connection) DeleteByID(e db.Entry, ids ...primitive.ObjectID) error
- func (c *Connection) Find(e db.Entry, results any, filter bson.M, optionalOpts ...db.FindOptions) error
- func (c *Connection) FindOne(e db.Entry, filter bson.M, optionalOpts ...db.FindOptions) error
- func (c *Connection) GetDB() *mongo.Database
- func (c *Connection) Insert(e ...db.Entry) error
- func (c *Connection) RegisterEntries(entries ...db.Entry)
- func (c *Connection) UpdateByID(e db.Entry) error
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) DeleteByID ¶
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
Click to show internal directories.
Click to hide internal directories.