Is CRUD API of NeDB compatibale with MongoDB?

I am looking for MongoDB API compatible DB engine that does not require a full blown mongod process to run (kind of SQLite for Node).

From multiple candidates that persistently store data on a local disk with similar API ended up with two:

Problem

  • I have worked with neither of them.
  • I am also very new to the API of MongoDB, so it is difficult for me to judge about comparability.

Requirements

I need your help/advice on picking only one library that satisfies

  • It is stable enough.
  • It is fast to handle ~1Mb JSON documents on disk or bigger.
  • I want to be able to switch to MongoDB as a data backend in the future or by demand by changing a config file. I don't want to duplicate code.

DB initialization api is different

Now only tingodb claims the API compatibility. Even initialization looks fairly similar.

tingodb

var Db = require('tingodb')().Db, assert = require('assert');

vs

mongodb

var Db = require('mongodb').Db,
    Server = require('mongodb').Server,
    assert = require('assert');

In case of NeDB it looks a bit different because it uses the datastore abstraction:

// Type 1: In-memory only datastore (no need to load the database)
var Datastore = require('nedb')
  , db = new Datastore();

QUESTION

Obliviously initialization is not compatible. But what about CRUD? How difficult it is to adopt it?

Since most of the code I do not want to duplicate will be CRUD operations, I need to know how similar they are, i.e. how agnostic can be my code about the fact which backend I have.

// If doc is a JSON  object to be stored, then

db.insert(doc); // which is a NeDB method which is compatiable

// How about *WriteResult*? does not look like it..

db.insert(doc, function (err, newDoc) {   // Callback is optional
  // newDoc is the newly inserted document, including its _id
  // newDoc has no key called notToBeSaved since its value was undefined
});

I will appreciate your insight in this choice!


Also see:

NeDB CRUD operations are upwards compatible with MongoDB, but initialization is indeed not. NeDB implements part of MongoDB's API but not all, the part implemented is upwards compatible.

It's definitely fast enough for your requirements, and we've made it very stable over the past few months (no more bug reports)