db

package
v0.0.0-...-b11ff8e Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongo

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

Mongo creates and manages the db message queue connection

func (*Mongo) AddRecord

func (m *Mongo) AddRecord(database string, collection string, record any) (string, error)

AddRecord inserts a record into the db database

func (*Mongo) Connect

func (m *Mongo) Connect() error

Connect to the db server

func (*Mongo) Disconnect

func (m *Mongo) Disconnect() error

Disconnect from the db server

func (*Mongo) GetClient

func (m *Mongo) GetClient() *mongo.Client

GetClient retrieves the raw db connection

func (*Mongo) GetConfig

func (m *Mongo) GetConfig() MongoConfig

GetConfig get the db config

func (*Mongo) Init

func (m *Mongo) Init() (*Mongo, error)

Init create a new db manager with a given config

func (*Mongo) RemoveRecord

func (m *Mongo) RemoveRecord(database string, collection string, id string) error

RemoveRecord deletes a record into the db database

func (*Mongo) ReplaceRecord

func (m *Mongo) ReplaceRecord(database string, collection string, id string, record any) error

ReplaceRecord update a record in the db database

func (*Mongo) RetrieveAll

func (m *Mongo) RetrieveAll(database string, collection string, result any) error

RetrieveAll get all documents in a collection Needs to be an array of interfaces

func (*Mongo) RetrieveFiltered

func (m *Mongo) RetrieveFiltered(database string, collection string, filter bson.D, result any) error

RetrieveFiltered get all documents in a collection Needs to be an array of interfaces

func (*Mongo) RetrieveOne

func (m *Mongo) RetrieveOne(database string, collection string, id string, result any) error

RetrieveOne get a single document in a collection

type MongoConfig

type MongoConfig struct {
	Host string
	User string
	Pass string
}

MongoConfig configuration structure for the db db

func (*MongoConfig) FromEnv

func (n *MongoConfig) FromEnv() (*MongoConfig, error)

FromEnv creates a nats config using environmental variables

func (*MongoConfig) IsSet

func (n *MongoConfig) IsSet() bool

IsSet checks if the configuration has been set Note: All fields required

Jump to

Keyboard shortcuts

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