3

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:

Community
  • 1
  • 1
Yauhen Yakimovich
  • 13,635
  • 8
  • 60
  • 67
  • Question: "Is NeDB MongoDB compatible? If not, how difficult it is to adopt it?" 1. In some ways, there is a sub-set of compatibilty. Read the manual page. 2. ???? not sure what you mean. But really your question really seems to be that one line with just a possible explaination of what you mean on point **2** – Neil Lunn Jul 23 '14 at 14:29
  • I have edited the question now to only "CRUD compatible". Thanks! – Yauhen Yakimovich Jul 23 '14 at 14:32
  • In limited terms then again "Yes", but in a limited way. This is not the place to ask for recommendations though. You were already given advice to read the manual and essentially do your own testing. – Neil Lunn Jul 23 '14 at 14:35
  • @NeilLunn: do you have any experience with these tools? – Yauhen Yakimovich Jul 23 '14 at 14:40
  • 1
    I too have worked with NeDB at least. There are others such as minimongo in meteor. None are what SQLite is to SQL for the analogy. Basic things are okay but when you really want to test on scale then just use the original. – Neil Lunn Jul 23 '14 at 14:42
  • @NeilLunn: So NeDB CRUDs results handling either vial callbacks or return values is just too different, right? I would actually take it as a NO answer then. It is too much work. Thanks. Was helpful for me. – Yauhen Yakimovich Jul 23 '14 at 14:48
  • I am not providing an "anwswer" as I don't see the usefulness to may people. Again, look at the manual pages. There are many MongoDB operations such as update operators and query operators and aggregation and mapReduce and the list goes on. MongoDB "look alikes" are far too immature to take seriously at present. – Neil Lunn Jul 23 '14 at 15:12

1 Answers1

3

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)

Louis Chatriot
  • 2,031
  • 2
  • 15
  • 13