mongodb

package
v0.0.0-...-a483330 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ConnectionURL string `json:"connectionUrl"`
	Database      string `json:"database"`
}

Config provides options to establish connection to mongo db

type Mongodb

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

Mongodb struct

func New

func New(c *Config) *Mongodb

New returns new *Mongodb struct with passed config

func (*Mongodb) Close

func (m *Mongodb) Close() error

Close calls func disconnect for mongo

func (*Mongodb) CreateRecords

func (m *Mongodb) CreateRecords(q QueryInsert) (ok bool, err error)

CreateRecords creates new records according to passed QueryInsert

func (*Mongodb) GetRecords

func (m *Mongodb) GetRecords(q QueryGet) ([]map[string]interface{}, error)

func (*Mongodb) Open

func (m *Mongodb) Open() error

Open initialises new mongodb client

type QueryGet

type QueryGet struct {
	Collection string                 `json:"collection"`
	Query      map[string]interface{} `json:"query"`
}

QueryGet describes to perform retrieving mongo records

type QueryInsert

type QueryInsert struct {
	Collection string                   `json:"collection"`
	Query      []map[string]interface{} `json:"query"`
}

QueryInsert describes interface to insert mongo records

Jump to

Keyboard shortcuts

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