TingoDB

0.6.1 · abandoned · verified Wed Apr 22

TingoDB is an embedded JavaScript database for Node.js, designed to be upwardly compatible with MongoDB's v1.4 API. It can operate either as an in-process filesystem database, storing data on disk, or entirely in memory. While the npm metadata shows version 0.6.1 and a README excerpt mentions an `apiLevel` parameter in 0.6.x for some 2.x specific behaviors, the project appears to be largely abandoned, with the last update noted in 2015/2018 and the author explicitly stating its abandonment in 2019. Its key differentiator was offering a local, file-based or in-memory data store with a familiar MongoDB-like query interface, rigorously tested using portions of the official MongoDB Node.js driver's test suite, allowing it to potentially serve as a drop-in replacement for applications built against older MongoDB driver versions.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing TingoDB to a local file path, creating a collection, inserting multiple documents, and querying for them, mirroring MongoDB's v1.4 API behavior.

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

const dbPath = process.env.TINGODB_PATH || './data'; // Specify a path for persistent storage

// Initialize Db. The second argument is for options, e.g., { apiLevel: 200 }
const db = new Db(dbPath, {});

// Fetch a collection to insert documents into
const collection = db.collection("batch_document_insert_collection_safe");

// Insert multiple documents
collection.insert([{hello:'world_safe1'}, {hello:'world_safe2'}], {w:1}, function(err, result) {
  assert.equal(null, err);
  console.log('Inserted documents:', result);

  // Fetch a document
  collection.findOne({hello:'world_safe2'}, function(err, item) {
	assert.equal(null, err);
	console.log('Found item:', item);
	assert.equal('world_safe2', item.hello);

    // Example of finding all documents
    collection.find({}).toArray(function(err, docs) {
        assert.equal(null, err);
        console.log('All documents:', docs);
        // In a real app, you'd close the DB connection here if it's not reused
    });
  });
});

view raw JSON →