Optional
options: { Optional
deserializeOptional
lazyOptional
megachunkOptional
onOptional
onOptional
onversionchange?: ((versionChangeEvent: IDBVersionChangeEvent) => void)Optional
serializeDeletes a database from IndexedDB
// DELETE DATABASE
// delete 'finance'/'test' value from catalog
idbAdapter.deleteDatabase('test', function {
// database deleted
});
IncrementalIndexedDBAdapter
the name of the database to delete from IDB
(Optional) executed on database delete
Retrieves a serialized db string from the catalog.
// LOAD
var idbAdapter = new IncrementalIndexedDBAdapter();
var db = new loki('test', { adapter: idbAdapter });
db.loadDatabase(function(result) {
console.log('done');
});
IncrementalIndexedDBAdapter
the name of the database to retrieve.
callback should accept string param containing serialized db string.
Incrementally saves the database to IndexedDB
var idbAdapter = new IncrementalIndexedDBAdapter();
var db = new loki('test', { adapter: idbAdapter });
var coll = db.addCollection('testColl');
coll.insert({test: 'val'});
db.saveDatabase();
IncrementalIndexedDBAdapter
the name to give the serialized database
returns copy of the Loki database
(Optional) callback passed obj.success with true or false
Generated using TypeDoc
An improved Loki persistence adapter for IndexedDB (not compatible with LokiIndexedAdapter) Unlike LokiIndexedAdapter, the database is saved not as one big JSON blob, but split into small chunks with individual collection documents. When saving, only the chunks with changed documents (and database metadata) is saved to IndexedDB. This speeds up small incremental saves by an order of magnitude on large (tens of thousands of records) databases. It also avoids Safari 13 bug that would cause the database to balloon in size to gigabytes
Example
Param
Configuration options for the adapter
Param
Function to call on
IDBDatabase.onversionchange
event (most likely database deleted from another browser tab)Param
Function to call once IDB load has begun. Use this as an opportunity to execute code concurrently while IDB does work on a separate thread
Param
Called when this adapter is forced to overwrite contents of IndexedDB. This happens if there's another open tab of the same app that's making changes. You might use it as an opportunity to alert user to the potential loss of data
Param
Called with a chunk (array of Loki documents) before it's saved to IndexedDB. You can use it to manually compress on-disk representation for faster database loads. Hint: Hand-written conversion of objects to arrays is very profitable for performance. If you use this, you must also pass options.deserializeChunk.
Param
Called with a chunk serialized with options.serializeChunk Expects an array of Loki documents as the return value
Param
Number of parallel requests for data when loading database. Can be tuned for a specific application
Param
Names of collections that should be deserialized lazily Only use this for collections that aren't used at launch