MongoDB API wrapper
npm install api-mongodb#### Requirements:
1. 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:
`bash
$ npm install;
$ npm test;
$ npm start;
`
#### Basic usage
`javascript
const MongoClient = require("api-mongodb");
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
Operation | Parameters | Unit test
------------- | ------------- | --------------
insertDocument | collection:String, data:Object | ✓
getDocumentByID | id:ObjectID | ✓
updateDocument | collection:String, id:ObjectID, data:Object | ✓
deleteDocument | { collection:String, id:ObjectID } | ✓
#### Tests
`bash`
$ npm test
`bash
Mongo API
Methods
✓ insertDocument
✓ getDocumentByID
✓ searchCollectionsForDocumentWithID
✓ updateDocument
✓ deleteDocument
✓ createCollectionWithUniqueIndices
✓ createCollectionWithTemporaryDocuments
✓ done
8 passing (89ms)
``