0.1.4 • Published 3 years ago

api-mongodb v0.1.4

Weekly downloads
97
License
UNLICENSED
Repository
github
Last release
3 years ago

api-mongodb

A non-relational database wrapper for 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:

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

Basic usage

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

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

Tests

$ npm test
  Mongo API
    Methods
      ✓ insertDocument
      ✓ getDocumentByID
      ✓ searchCollectionsForDocumentWithID
      ✓ updateDocument
      ✓ deleteDocument
      ✓ createCollectionWithUniqueIndices
      ✓ createCollectionWithTemporaryDocuments
      ✓ done

  8 passing (89ms)
0.1.4

3 years ago

0.1.3

3 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

7 years ago