0.0.1 • Published 7 years ago

mongodb-client v0.0.1

Weekly downloads
18
License
MIT
Repository
github
Last release
7 years ago

mongodb-client

NPM version build status Test coverage David deps npm download

A nice API client for MongoDB.

Features

  • Make API as same as MongoDB CRUD Reference
  • Reading the source codes just like reading the document of MongoDB client.
  • Fix native mongodb insertedIds data format error on options.ordered = false.
  • Remove insert() method, please use the more clear insertMany() and insertOne() instead.
  • Disable options.forceServerObjectId on write methods.
  • ...

Installation

$ npm install mongodb-client

Quick start

const co = require('co');
const MongoDB = require('mongodb-client');

const db = new MongoDB('mongodb://localhost:27017/myproject');
// listen db connect error event
db.on('error', err => {
  console.error(err);
});
// wait for db connected
db.ready(() => {
  // let's read and write
  co(function*() {
    const result = yield db.collection('user').insertMany([
      { name: 'fengmk2', type: 'JavaScript' },
      { name: 'dead-horse', type: 'JavaScript' },
      { name: 'tj', type: 'go' },
    ]);
    console.log(result);

    const docs = yield db.collection('user').find({ type: 'JavaScript' }).skip(10).toArray();
    console.log(docs);
  }).catch(err => {
    console.error(err);
    console.error(err.stack);
  });
});

License

MIT


APIs

CURD

Insert Documents

TBD

Modify Documents

TBD

Query Documents

TBD

Remove Documents

Indexes

TBD

Aggregation

TBD

Administration

TBD