Documentation ¶
Index ¶
- type DB
- func (db *DB) CheckIfCollectionExists(collectionName string) (bool, error)
- func (db *DB) ConfigureCollections() error
- func (db *DB) ConfigureTimeSeriesCollections() error
- func (db *DB) CreateCollection(collectionName string, ...) error
- func (db *DB) FindAllFromFilter(collectionName string, filter bson.M) (*mongo.Cursor, error)
- func (db *DB) FindOne(collectionName string, filter bson.M) (*mongo.SingleResult, error)
- func (db *DB) FirstStartDBMigrations() error
- func (db *DB) InsertMany(collectionName string, data []interface{}) error
- func (db *DB) InsertOne(collectionName string, data bson.M) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
func (*DB) CheckIfCollectionExists ¶
CheckIfCollectionExists is used to check if a further DB initialisation is required. Returns true if a Collection with that name exists
func (*DB) ConfigureCollections ¶
ConfigureCollections to be run on startup to check that a number of different Collections exist Creates the collections if not already exist
func (*DB) ConfigureTimeSeriesCollections ¶
func (*DB) CreateCollection ¶
func (db *DB) CreateCollection(collectionName string, collectionCreationParams ...*options.CreateCollectionOptions) error
CreateCollection creates a collection with a specified name and with creationParameters It does NOT check if the collection already exists and will return an error for sure if it does.
func (*DB) FindAllFromFilter ¶
FindAllFromFilter returns a mongo.Cursor that can be iterated over In order to return all the documents you need to have an empty filter
func (*DB) FindOne ¶
FindOne returns one document from the specified collection Returns a bson.M that needs to be decoded ( bson.M.decode() ) You need to check if the result.Err() is mongo.ErrNoDocuments if it returns Err
func (*DB) FirstStartDBMigrations ¶
func (*DB) InsertMany ¶
InsertMany inserts many documents into the specified collection Uses bson.M which does NOT care about the order of the json fields and data