Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

api-mongo

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-mongo

MongoDB API wrapper

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

api-mongo

A non-relational database wrapper for MongoDB

Requirements:

  • mongodb 2.2.10

Getting started

Make sure your database is running and listening on port 27017. You can do that by running bash $ mongod.

Once the database is running, and your configuration is in place, you can run this package:

$ npm install;
$ npm test;
$ npm start;

Basic usage

const MongoClient = require("api-mongo");
const url = 'mongodb://localhost:27017/test';
const mongo = new MongoClient(url);

let person = {};
person.givenName = 'Jose';
person.familyName = 'Barrios';

//Insert document to collection
mongo.insertDocument('people', data)
    .then(res => {
        //Do something with DB response
        console.log(res);
    })
    .catch(err =>{
        //Handle error response
        console.error(err);
    })

Public Methods

OperationParametersUnit test
insertDocumentcollection:String, data:Object
getDocumentByIDid:ObjectID
updateDocumentcollection:String, id:ObjectID, data:Object
deleteDocument{ collection:String, id:ObjectID }

Keywords

Mongo

FAQs

Package last updated on 17 Nov 2017

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