mongodb

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mongodb contains the domain concept definitions needed to support Magistrala Mongo database functionality.

It provides the abstraction of the Mongo database service, which is used to configure, setup and connect to the Mongo database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg Config) (*mongo.Database, error)

Connect creates a connection to the MongoDB instance.

func Setup

func Setup(envPrefix string) (*mongo.Database, error)

Setup load configuration from environment, create new MongoDB client and connect to MongoDB server.

Types

type Config

type Config struct {
	Host string `env:"HOST" envDefault:"localhost"`
	Port string `env:"PORT" envDefault:"27017"`
	Name string `env:"NAME" envDefault:"messages"`
}

Config defines the options that are used when connecting to a MongoDB instance.

Jump to

Keyboard shortcuts

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