1.0.8 • Published 3 years ago

mongozavr v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

mongozavr

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"});
updateOne example
const Mongo = require("mongozavr");
await mongo.updateOne('someCollectionName', {_id, "5e318aa8473d790943408095"}, {$set:{"foo": "bar"}, $push: {"someArrayField":"some item"}});

API

static getRandomId() - returns random mongodb ObjectId
insert(collection, documents)
find(collection, searchParams, options)
findOne(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)
replace(collection, searchParams, updateParams, options)
replaceOne(collection, searchParams, updateParams, options)
1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago