mongodb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

mongodb

Configuration

  • Hosts (List of String): MongoDB host(s)
    • Mandatory: true
  • Username (String): MongoDB username
    • Mandatory: false
  • Password (String): MongoDB password
    • Mandatory: false
  • ReplicaSet (String): MongoDB replica set name
    • Mandatory: false
  • Database (String): Database name
    • Mandatory: true
  • Timeout (Int): MongoDB connection timeout
    • Mandatory: true

Example

import (
  "github.com/ChaosHQ/common-lib/mongodb"
  "fmt"
)

// load log config and other configs via edict
// TODO: Add Example

Documentation

Overview

Package mongodb ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Username   string   `json:"Username" yaml:"Username"`
	Password   string   `json:"Password" yaml:"Password"`
	Hosts      []string `json:"Hosts" yaml:"Hosts"`
	Database   string   `json:"Database" yaml:"Database"`
	ReplicaSet string   `json:"ReplicaSet" yaml:"ReplicaSet"`
	Timeout    int      `json:"Timeout" yaml:"Timeout"`
}

Config ...

type Mongo

type Mongo struct {
	DB     *mongo.Database
	Client *mongo.Client
}

Mongo ...

func Load

func Load(config Config) (*Mongo, error)

Load ...

func (*Mongo) Close

func (m *Mongo) Close() error

Close ...

func (*Mongo) Collection

func (m *Mongo) Collection(name string) *mongo.Collection

Collection ...

Jump to

Keyboard shortcuts

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