Documentation ¶
Index ¶
- Constants
- Variables
- func FilterEquals(key string, val string) interface{}
- type DBKV
- type MongoClient
- func (mc *MongoClient) FindDocuments(filter interface{}, res interface{}, opts ...*options.FindOptions) error
- func (mc *MongoClient) FindOneDocument(filter interface{}, res interface{}) error
- func (mc *MongoClient) GetKey(key string) (string, error)
- func (mc *MongoClient) GetRecent(skip int, limit int) ([]DBKV, error)
- func (mc *MongoClient) InsertDocument(doc interface{}) error
- func (mc *MongoClient) SetKey(key string, value string) error
- func (mc *MongoClient) Start() error
- func (mc *MongoClient) Stop() error
- func (mc *MongoClient) UpdateDocument(filter interface{}, doc interface{}) error
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 ¶
Types ¶
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:
- ErrNoDocuments
- 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) 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
Click to show internal directories.
Click to hide internal directories.