2.0.0 • Published 6 years ago

mangodb-client v2.0.0

Weekly downloads
17
License
SEE LICENSE IN LI...
Repository
github
Last release
6 years ago

mangodb-client

Build Status NPM version

A powerful MangoDB client for Node.js

Most users just want to get started quickly without getting weighed down by features. The mangodb-client brings a whole new level of simplicity. Happy sharting!

Installation

npm install --save mangodb-client

Usage

// Node auto-discovery. Or use any config format of your own invention!
const db = require('mangodb-client')();

// Write something (guaranteed consistency)
db.put('key', 'value', error => {
    if (error) {
      // Not even worried
    } else {
      console.log('cool')
    }
});

// And with Promises
db.put('key', 'value').then(() => console.log('yep'));



// Read something (predictive result, which will self-correct
// if the server sends a more accurate response).
db.get('key', (error, {key, value}) => {
  if (error) {
    // Still not worried
  } else {
    console.log(`Got ${value} at ${key}`)
  }
});

// And with Promises
db.get('key').then(({key, value}) => console.log(`Got ${value} at ${key}`));