Registry / database / tingodb

tingodb

JSON →
library0.6.1jsnpmunverified

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.

npm install tingodb
INSTALL
IMPORT
SIG · TINGODB
T
tingodb
databasejavascriptv0.6.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Db
const Db = require('tingodb')().Db;
const { Db } = require('tingodb'); const Db = require('tingodb').Db;
The `tingodb` module exports a factory function, which must be invoked to obtain the object containing the `Db` constructor.
tingodb (factory function)
const tingodbFactory = require('tingodb'); // Usage: const { Db } = tingodbFactory({ apiLevel: 140 });
import tingodbFactory from 'tingodb';
The direct `require('tingodb')` call returns a function (the factory) that takes configuration options and returns the module object with classes like `Db`.
Collection
// Collection instances are obtained from a Db object: // const collection = db.collection('mycollection');
The `Collection` object is not directly imported but instantiated via `db.collection()`. This entry serves to highlight that common MongoDB-like objects are accessed through the `Db` instance rather than direct imports, consistent with MongoDB Node.js driver's 1.x API.

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 }); }); });
Debug
Known issues
breakingThe `apiLevel` configuration parameter was introduced in version 0.6.x. Its default value of `140` (for MongoDB API 1.4.x compatibility) means behavior, such as `findAndModify` return values, might differ if not explicitly set, especially when aiming for experimental 2.x API behavior using `apiLevel: 200`.
fix
Explicitly set `apiLevel` in the factory function call, e.g., `require('tingodb')({ apiLevel: 140 })` to ensure consistent behavior with MongoDB 1.4.x, or `apiLevel: 200` for 2.x behaviors.
affects: >=0.6.0
gotchaTingoDB is explicitly compatible with MongoDB's v1.4 API level. Many features, commands, or query operators introduced in later MongoDB versions (e.g., 2.x, 3.x, or modern versions) are not supported. Using TingoDB as a drop-in for newer MongoDB drivers will lead to unexpected errors or unsupported operations.
fix
Ensure your application only uses MongoDB features and API calls available in MongoDB version 1.4.x. If newer features are required, a full MongoDB instance is necessary.
affects: >=0.1.0
gotchaThe `require('tingodb')` call does not directly return the module object with classes. Instead, it returns a factory function that must be invoked (`require('tingodb')()`) to get the usable module object containing constructors like `Db`.
fix
Always call the required module as a function: `const TingoDBModule = require('tingodb')();` before accessing `TingoDBModule.Db`.
affects: >=0.1.0
gotchaAs an embedded, in-process database, TingoDB lacks network capabilities, replication, sharding, or advanced security features inherent to a full MongoDB server. It's designed for local storage or in-memory operations, not as a networked database server.
fix
TingoDB is suitable for lightweight, local data persistence. For networked, scalable, or production-grade database solutions, a full MongoDB deployment is required.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: require('tingodb').Db is not a constructor
Attempting to access the `Db` constructor directly from the `tingodb` module without invoking the factory function.
fix
The `tingodb` module exports a function that must be called to return the object containing the `Db` constructor. Use `const Db = require('tingodb')().Db;`
MongoError: Unsupported operator: $someNewOperator
Using MongoDB query operators or commands that were introduced in versions of MongoDB beyond 1.4.x, which TingoDB does not support.
fix
Consult MongoDB 1.4.x documentation to ensure all queries and operations are compatible with that specific API level. Rewrite queries to use supported operators.
Error: ENOENT: no such file or directory, open '/nonexistent/path/tingodb.db'
TingoDB is configured to use a filesystem path for storage, but the specified directory does not exist or the application lacks write permissions.
fix
Ensure the directory specified in `new Db('/some/local/path', {})` exists and is writable by the Node.js process, or handle directory creation before initializing the database.
Upgrade
Version history
0.6.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
Meta
1
OpenAI (training)
1
Resources
tingodb — npm install tingodb · libregistry