database

package
v0.0.0-...-640912d Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MongoDatabase   = "nlib"
	MongoCollection = "logs"
)

Variables

View Source
var (
	ErrNoDocuments = errors.New("no documents")
)

Functions

func FilterEquals

func FilterEquals(key string, val string) interface{}

Types

type DBLogs

type DBLogs struct {
	Level     string                 `json:"level" bson:"level"`
	Message   string                 `json:"message" bson:"message"`
	Details   map[string]interface{} `json:"details" bson:"details"`
	Timestamp int64                  `json:"timestamp" bson:"timestamp"`
}

type MongoClient

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

func NewMongoClient

func NewMongoClient(mongoURI string) *MongoClient

func (*MongoClient) AddLogs

func (mc *MongoClient) AddLogs(level string, message string, details map[string]interface{}) error

func (*MongoClient) FindDocuments

func (mc *MongoClient) FindDocuments(filter interface{}, res interface{}, opts ...*options.FindOptions) error

func (*MongoClient) FindOneDocument

func (mc *MongoClient) FindOneDocument(filter interface{}, res interface{}) error

func (*MongoClient) GetLogs

func (mc *MongoClient) GetLogs(n int, skip int) ([]DBLogs, error)

func (*MongoClient) InsertDocument

func (mc *MongoClient) InsertDocument(doc interface{}) error

func (*MongoClient) Start

func (mc *MongoClient) Start() error

func (*MongoClient) Stop

func (mc *MongoClient) Stop() error

func (*MongoClient) UpdateDocument

func (mc *MongoClient) UpdateDocument(filter interface{}, doc interface{}) error

type MongoConfig

type MongoConfig struct {
	URI      string `yaml:"uri" mapstructure:"uri"`
	Database string `yaml:"database" mapstructure:"database"`
}

Jump to

Keyboard shortcuts

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