1.0.0 • Published 5 years ago

monozavr v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

downloader

Simple client for mongodb

Installing

$ npm install mongozavr

Example

Basic usage
const Mongo = require("mongozavr");
const mongo = new Mongo({url: "mongodb://127.0.0.1:27017", db: "someDbName"});
const _id = Mongo.getRandomId();
await mongo.insert('someCollectionName', {_id, "foo": "bar"});
await mongo.find('someCollectionName', {}, {"limit":10, "skip":10, "sort":{"_id":-1}});
With collection binding
const Mongo = require("mongozavr");
const mongo = new Mongo({url: "mongodb://127.0.0.1:27017", db: "someDbName", collections: "someCollectionName"});
const _id = Mongo.getRandomId();
await mongo.insert({_id, "foo": "bar"});
await mongo.find({}, {"limit":10, "skip":10, "sort":{"_id":-1}});
Finding by _id without using ObjectId
const Mongo = require("mongozavr");
await mongo.find('someCollectionName', {_id, "5e318aa8473d790943408095"});
await mongo.update('someCollectionName', {_id, "5e318aa8473d790943408095"}, {"foo": "bar"});

API

static getRandomId() - returns random mongodb ObjectId
insert(collection, documents)
find(collection, searchParams, options)
count(collection, searchParams, options)
remove(collection, searchParams, options)
removeOne(collection, searchParams, options)
update(collection, searchParams, updateParams, options)
updateOne(collection, searchParams, updateParams, options)
1.0.0

5 years ago