Sitelet https://web.archive.org/web/20201112013455/https://github.com/node-modules/mongodb-client
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

About

A nice API client for MongoDB.

Resources

License

Packages

No packages published
You can’t perform that action at this time.