Registry / database / taffydb

taffydb

JSON →
library2.7.3jsnpmunverified

TaffyDB is an open-source JavaScript library that provides an in-memory database solution for both browser and Node.js environments. It allows developers to store and manipulate JSON data as 'tables' using a uniform, SQL-like interface. Currently at version 2.7.3, the library emphasizes stability and reliability, having been used in production for many years. It differentiates itself by offering a JavaScript-centric data selection engine with features like insert, update, unique, and count, all while being compatible with various DOM libraries and modern browsers (IE9+, FF3+, Safari 5+, Chrome 1.0+) and Node.js 0.10+. While stable, the project's focus appears to be on expanding regression test coverage rather than rapid feature development, suggesting a maintenance-oriented release cadence.

npm install taffydb
INSTALL
IMPORT
SIG · TAFFYDB
T
taffydb
databasejavascriptv2.7.3
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.

TAFFY
const TAFFY = require('taffy').taffy;
const TAFFY = require('taffy');
In Node.js, the main export of the 'taffy' package is an object containing the 'taffy' function. You must access it via `.taffy` to get the database constructor. In browsers, `TAFFY` is typically exposed as a global variable.
TAFFY
<!-- Add <script src="taffy.js"></script> in HTML --> // TAFFY is now a global function
import TAFFY from 'taffy';
TaffyDB is designed for CommonJS or global browser usage. There is no official ESM export, so direct `import` statements for `TAFFY` will fail. For browser usage, include the script tag and access the global `TAFFY`.

This quickstart demonstrates how to initialize a TaffyDB instance with JSON data, perform basic queries using SQL-like syntax (e.g., less than), update records, and select specific fields.

const TAFFY = require('taffy').taffy; const product_db = TAFFY([ { "item": 1, "name": "Blue Ray Player", "price": 99.99 }, { "item": 2, "name": "3D TV", "price": 1799.99 }, { "item": 3, "name": "Soundbar", "price": 149.99 } ]); console.log('All products:', product_db().get()); // Query for items with price less than 150 const lowPricedItems = product_db({price: {lt: 150}}).get(); console.log('Low priced items (price < 150):', lowPricedItems); // Update the price of an item product_db({item: 1}).update({price: 89.99}); console.log('Updated Blue Ray Player:', product_db({item: 1}).first()); // Select only names const productNames = product_db().select("name"); console.log('Product names:', productNames);
Debug
Known issues
gotchaWhen using TaffyDB in Node.js, you must specifically access the `taffy` function from the `require('taffy')` object (e.g., `require('taffy').taffy`). Requiring the package directly without `.taffy` will not return the database constructor.
fix
Change `const TAFFY = require('taffy');` to `const TAFFY = require('taffy').taffy;`
affects: >=0.1.0
gotchaTaffyDB is a legacy library that does not provide native ES Module (ESM) exports. Attempting to use `import TAFFY from 'taffy';` or similar ESM syntax will result in errors in modern JavaScript environments that enforce ESM.
fix
For Node.js, use `const TAFFY = require('taffy').taffy;`. For browser environments, load `taffy.js` via a `<script>` tag and use the global `TAFFY` variable.
affects: >=0.1.0
gotchaTaffyDB is an in-memory database, meaning all data is stored in the application's RAM. It does not provide persistence out-of-the-box. If the application restarts or the browser tab is closed, all data will be lost unless manually saved and loaded.
fix
Implement manual data persistence by serializing the database content (e.g., `db().get()`) to local storage, IndexedDB, or a server, and then re-initializing the database upon application startup.
affects: >=0.1.0
gotchaThe documentation mentions compatibility with Node.js 0.10+. While the library is stable, its support for modern Node.js features (e.g., async/await, streams, newer event loop patterns) may be limited, and it might not be actively tested against the latest Node.js LTS versions.
fix
Thoroughly test TaffyDB's behavior in your specific modern Node.js environment before deploying to production. Consider alternative, more actively maintained in-memory database solutions for new projects if deep modern Node.js integration is required.
affects: <2.7.3
Errors
Common errors & fixes
TypeError: taffy is not a function
Attempting to call `require('taffy')` directly as a function in Node.js.
fix
You need to access the `taffy` property from the required object: `const TAFFY = require('taffy').taffy;`
SyntaxError: Cannot use import statement outside a module
Attempting to use `import TAFFY from 'taffy';` in a CommonJS-only or non-module context.
fix
TaffyDB does not provide an ESM export. Use `const TAFFY = require('taffy').taffy;` in Node.js or load it via a `<script>` tag in the browser and use the global `TAFFY` variable.
TAFFY is not defined
Trying to use `TAFFY` in a browser environment without including the `taffy.js` script or before the script has loaded.
fix
Ensure you have `<script src="path/to/taffy.js"></script>` in your HTML before attempting to use the `TAFFY` global function.
Upgrade
Version history
2.7.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources