Registry / database / ydn.db

ydn.db

JSON →
library1.3.0jsnpmunverified

A unified client-side database library for IndexedDB, WebSQL, and localStorage, currently at stable version 1.3.0. It provides a consistent asynchronous API across storage backends, supports schema version migration, advanced queries (including SQL-like and full-text search via additional modules), and transaction workflow management. Key differentiators include support for legacy browsers (IE6+, Chrome 4+, etc.), on-the-fly schema generation, managed requests to avoid InvalidStateError, and high-performance index queries using AVL trees for localStorage. Actively maintained until 2016, now in maintenance mode.

npm install ydn.db
INSTALL
IMPORT
SIG · YDN.DB
Y
ydn.db
databasejavascriptv1.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

ydn.db.Storage
✓ var db = new ydn.db.Storage('db-name', schema);
✗ import Storage from 'ydn.db'
Global variable 'ydn' is used via script tag; no npm module. Use global in browser.
ydn.db.Storage
✓ const db = new ydn.db.Storage('db-name');
✗ const db = new Storage('db-name');
Always prefix with 'ydn.db.'.
ydn.db.Storage
✓ <script src='ydn.db.min.js'></script>
✗ require('ydn-db')
Not available as npm package. Use CDN or download from website.

Shows how to open a database with schema, store and retrieve a record, and query using an index.

// Include ydn.db in HTML: <script src='https://cdn.jsdelivr.net/npm/ydn-db@1.3.0/dist/ydn.db.min.js'></script> var schema = { stores: [{ name: 'people', indexes: [{ name: 'age' }] }] }; var db = new ydn.db.Storage('my-db', schema); db.put('people', { name: 'Alice', age: 30 }, 'id1'); db.get('people', 'id1').done(function(record) { console.log(record); }); db.from('people').where('age', '>=', 25).list(10).done(function(records) { console.log(records); }); db.close();
Debug
Known issues
deprecatedWebSQL is deprecated in many browsers and will be removed.
fix
Use IndexedDB backend by ensuring browser supports IndexedDB; avoid relying on WebSQL.
affects: >=1.0
gotchaStorage constructor expects a schema object, not a version number like IndexedDB.
fix
Pass schema as second argument: new ydn.db.Storage('name', schema).
affects: >=1.0
gotchaQueries using 'order' require a compound index defined in schema.
fix
Define compound index, e.g., ['age', 'name'] if ordering by 'name' after filtering by 'age'.
affects: >=1.0
breakingVersion 1.2 changed schema format: 'keyPath' now required for indexes.
fix
Add 'keyPath' property to index objects in schema.
affects: >=1.2
gotchaMethods return promises (jQuery-style) but not standard Promises; .done() and .fail() used.
fix
Use .done() for success, .fail() for error, not .then() .catch().
affects: >=1.0
Errors
Common errors & fixes
Uncaught TypeError: ydn.db is undefined
Library not loaded or script path incorrect.
fix
Ensure ydn.db.min.js is included before usage: <script src='ydn.db.min.js'></script>
InvalidStateError: A mutation operation was attempted on a database that did not allow mutations.
Attempting to put/get after closing database or during transaction that doesn't allow writes.
fix
Use managed requests: db.run() to wrap operations in transaction, or ensure db is open.
ydn.db.Storage: schema version is not defined
Missing required 'version' property in schema.
fix
Add 'version' to schema: { version: 1, stores: [...] }
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
Resources
packageydn.db ↗
ydn.db — npm install ydn.db · libregistry