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 = "kv"
)

Variables

View Source
var (
	ErrNoDocuments = errors.New("no documents")
)
View Source
var (
	NoFilter = bson.M{}
)

Functions

func FilterEquals

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

Types

type DBKV

type DBKV struct {
	Key     string `json:"key" bson:"key"`
	Value   string `json:"value" bson:"value"`
	Created int64  `json:"created" bson:"created"`
	Updated int64  `json:"updated" bson:"updated"`
}

type MongoClient

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

func NewMongoClient

func NewMongoClient(mongoURI string) *MongoClient

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) GetKey

func (mc *MongoClient) GetKey(key string) (string, error)

returned error:

  1. ErrNoDocuments
  2. others

func (*MongoClient) GetRecent

func (mc *MongoClient) GetRecent(skip int, limit int) ([]DBKV, error)

func (*MongoClient) InsertDocument

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

func (*MongoClient) SetKey

func (mc *MongoClient) SetKey(key string, value string) 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

Jump to

Keyboard shortcuts

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