Socket
Book a DemoInstallSign in
Socket

mongozavr

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongozavr

Simple client for mongodb

latest
Source
npmnpm
Version
1.0.8
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

mongodb

FAQs

Package last updated on 28 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts