[email protected]
Twitter
LinkedIn
YouTube
GitHub
  • Services
  • Blog
  • Repositories
  • GitHub
  • Resume
  • Contact
Product was added to your cart

Cart

Dexie.js: A simple and robust library for indexedDB (HTML5 Storage)

July 16, 2015Front-Endjfadev

Dexie.js is a simple and concise library to work with the “Indexed Database API” or IndexedDB.

IndexedDB it is a way of storing data persistently in the browser. Given that allows the creation of web applications with enhanced query capabilities, These can be run both online and offline. IndexedDB is useful for applications that store a lot of data and applications that do not need a permanent connection to the Internet to work.

It can also be very useful to save data to local in a hybrid app for example.

Example of use:

/*
|---------------------------------------------
| Make a database connection
|---------------------------------------------
*/

var db = new Dexie('MyDatabase');

// Define a schema
db.version(1)
    .stores({
        friends: 'name, age'
    });

// Open the database
db.open()
    .catch(function(error){
        alert('Uh oh : ' + error);
    });


/*
|---------------------------------------------
| Then run some queries
|---------------------------------------------
*/

// Find some old friends
db.friends
    .where('age')
    .above(75)
    .each(function(friend){
        console.log(friend.name);
    });

// or make a new one
db.friends
    .add({
        name: 'Camilla',
        age: 25
    });

Web: dexie.org

Documentation: GitHub

Repository

A Minimalistic Wrapper for IndexedDB
https://github.com/dexie/Dexie.js
694 forks.
14,110 stars.
588 open issues.

Recent commits:
  • fix(dexie-export-import): fix UTF-8 corruption for non-ASCII strings during import (#2259)* fix(dexie-export-import): fix UTF-8 corruption for non-ASCII strings during import (#2105)The streaming import reads a Blob in fixed-size byte chunks. When a chunkboundary falls inside a multi-byte UTF-8 sequence (e.g. Chinese/Japanesecharacters that occupy 3 bytes each), the partial byte sequence was decodedas a replacement character (U+FFFD / ��) instead of the correct character.Fix: switch from reading each slice as text (readBlobAsync/Sync with 'text')to reading it as an ArrayBuffer ('binary') and decoding with a TextDecoderin streaming mode ({ stream: true }). The TextDecoder buffers incompletemulti-byte sequences between chunks and emits them correctly once theremaining bytes arrive in the next chunk.Also add a regression test: 1000 records each containing 1000 repetitionsof the Chinese string '让我们说中文n' are exported and re-imported with a1 KB chunk size, then verified to contain no U+FFFD replacement characters.* fix: use fatal: true in TextDecoder to surface encoding errors loudly, GitHub
  • test(dexie-cloud): add unit tests for shouldOffloadBlob threshold behavior- Blob/File: always offloaded regardless of size (including 0-byte)- ArrayBuffer/TypedArray: threshold at 4096 bytes- Primitives/null/objects: never offloaded, David Fahlander
  • fix(dexie-cloud): always offload Blob/File objects regardless of size (#2182)Blob and File objects are now always offloaded to blob storage during sync,regardless of their size. Previously, only blobs >= 4KB were offloaded.This fixes #2182 where readBlobSync crashes in service workers becauseXMLHttpRequest is unavailable. By always offloading Blob/File objects,the data is never stored inline in IndexedDB, avoiding the need forsynchronous blob reading entirely.ArrayBuffer and TypedArray/DataView values retain the 4KB thresholdsince they don't have the same service worker limitation., David Fahlander
  • feat(dexie-cloud): Client-side blob offloading and lazy resolution- BlobRef format with _bt/_hasBlobRefs convention- Blob offloading: large binaries uploaded to blob storage, replaced with refs- Lazy blob resolution via blobResolveMiddleware- Eager blob downloader with parallel downloads (MAX_CONCURRENT=6)- Blob progress tracking (upload/download)- BlobSavingQueue for reliable blob persistence- TSON: transparent to BlobRefs (standard typedefs only)- get-object-diff: special-cases BlobRefs (same-ref = no diff)- Prepack hooks for workspace packages, GitHub
  • Use FinalizationRegistry for Dexie.connections and enforce maxConnections (#2254)* Refactor connection management to use FinalizationRegistry and maxConnectionsHistorically, Dexie tracked Dexie instances in a global 'connections'array to emulate 'versionchange' events and support BFCache. However,if developers forget to call close() on a Dexie instance, it remainsretained in this global array indefinitely, preventing garbage collection.This change replaces the global 'connections' array with a weaktracking mechanism using WeakRef and FinalizationRegistry. This allowsDexie instances that are no longer referenced by external code to beautomatically garbage collected, even if not explicitly closed.Chromium developers have observed an egregious number of connectionsaccumulating in real-world cases prior to this fix, leading tosignificant memory bloat in the browser process (hundreds of MiB).Additionally, this change introduces a 'maxConnections' limit(defaulting to 1000) to prevent unbounded growth of the number ofconnections if code unknowingly keeps references to a large numberof instances. db.open() will now throw a MaxConnectionsReachedErrorif this limit is exceeded.These changes significantly improve the memory efficiency of Dexieby default while maintaining backward compatibility and providingrobustness against connection leaks.* Replace the ConnectionTracker class and global connections array with asimpler WeakRef-based module (src/globals/connections.ts). Connections arenow tracked via a Set<WeakRef<Dexie>> with a FinalizationRegistry forautomatic cleanup when Dexie instances are garbage collected.Key changes:- Move maxConnections from a static property (Dexie.maxConnections) to a per-instance option in DexieOptions, defaulting to 1000- Replace ConnectionTracker class with smaller connection collection- Remove MaxConnectionsReached error — when the limit is exceeded, the oldest connection is evicted instead of throwing- Expose Dexie.connections as a getter that returns a snapshot array- Delete src/helpers/connection-tracker.ts* Fix coderabbit lack of undefined check* Remove unused Dexie import* Update connection handling to use db._novip———Co-authored-by: François Doray <[email protected]>Co-authored-by: David Fahlander <[email protected]>, GitHub

: Database, HTML5, IndexedDB, JS, Library, Storage, Web Developement

Services

  • Excel2chatGPT $10.00
  • Bot Tok $45.00 $40.00
  • Fix bugs in your PHP Symfony App $70.00 / hr
  • Fix bugs in your Wordpress Site $70.00 / hr
  • Tasks Automation using Node.js $70.00 / hr

Blog

  • How to Pay with a Bank Card on Cryptomus
  • Complete Beginner’s Guide to Bot Tok: Terminal Commands Explained
  • Top Site to Gain Views on TikTok
  • Jfa Whatsapp Chatbot
  • TikTok Bot

Explore

  • Free 10 Tiktok Likes
  • Free 2K TikTok Views
  • Free 100 TikTok Favorites
  • Free 300 TikTok Shares
  • Buy TikTok Views
  • Free 100 Instagram Likes
Twitter
LinkedIn
YouTube
GitHub

© 2013-2025 Jordi Fernandes Alves (@jfadev)