[email protected]
Twitter
LinkedIn
YouTube
GitHub
  • Serviços
  • Blog
  • Repositórios
  • GitHub
  • Currículo
  • Contato
Produto foi adicionado ao seu carrinho

Carrinho

Dexie.js: Uma biblioteca simples e robusta para indexedDB (HTML5 Storage)

Julho 16, 2015Front-endjfadev

Dexie.js é uma biblioteca simples e concisa para trabalhar com o “Indexed Database API” ou IndexedDB.

IndexedDB é uma maneira de armazenar dados persistentemente no navegador. Dado que permite a criação de aplicações web com recursos de consulta avançada, estes podem ser executados on-line e off-line. IndexedDB é útil para aplicativos que armazenam uma grande quantidade de dados e aplicações que não necessitam de uma ligação permanente à Internet para funcionar.

Também pode ser muito útil salvar dados em local em um aplicativo híbrido por exemplo.

Exemplo de uso:

/*
|---------------------------------------------
| 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

Documentação: GitHub

Repositório

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, Desenvolvimento Web

Serviços

  • Excel2chatGPT $10.00
  • Bot Tok $45.00 $40.00
  • Correção de bugs em seu aplicativo PHP Symfony $70.00 / hora
  • Correção de bugs em seu site Wordpress $70.00 / hora
  • Automação de tarefas usando Node.js $70.00 / hora

Blog

  • Como pagar com um cartão bancário em Cryptomus
  • Guia completo para iniciantes para o Bot Tok: Comandos do terminal explicados
  • Melhor site para obter visualizações no TikTok
  • Jfa Whatsapp Chatbot
  • Bot do TikTok

Explorar

  • Livre 10 Curtidas no TikTok
  • Visualizações 2K gratuitas do TikTok
  • Livre 100 Favoritos do TikTok
  • Livre 300 Compartilhamentos do TikTok
  • Comprar visualizações do TikTok
  • Livre 100 Curtidas no Instagram
Twitter
LinkedIn
YouTube
GitHub

© 2013-2025 Jordi Fernandes Alves (@jfadev)