Create a IndexedDBAdapter.
Optional
options: Partial<IndexedDBAdapterOptions>(Optional) configuration options for adapter
Private
#checkIDBAvailabilityPrivate
#closeDeletes a serialized db from the catalog.
// DELETE DATABASE
// delete 'finance'/'test' value from catalog
idbAdapter.deleteDatabase('test', function {
// database deleted
});
SylvieIndexedAdapter
the name of the database to delete from the catalog.
Optional
callback: ((_: Error | { (Optional) executed on database delete
Removes all database partitions and pages with the base filename passed in. This utility method does not (yet) guarantee async deletions will be completed before returning
SylvieIndexedAdapter
the base filename which container, partitions, or pages are derived
Retrieves object array of catalog entries for current app.
idbAdapter.getDatabaseList(function(result) {
// result is array of string names for that appcontext ('finance')
result.forEach(function(str) {
console.log(str);
});
});
SylvieIndexedAdapter
should accept array of database names in the catalog for current app.
Retrieves a serialized db string from the catalog.
// LOAD
var idbAdapter = new SylvieIndexedAdapter('finance');
var db = new loki('test', { adapter: idbAdapter });
db.loadDatabase(function(result) {
console.log('done');
});
the name of the database to retrieve.
callback should accept string param containing serialized db string.
Retrieves a serialized db string from the catalog, returns a promise to a string of the serialized database.
A promise to a string of the serialized database.
const db = new Sylvie(TEST_DB_NAME, {
adapter: new IndexedDBAdapter();
});
await db.loadDatabaseAsync({});
// db is now ready to use
// you can also chain the promises
await db.loadDatabaseAsync({}).then(() => {
// db is now ready to use
});
// or use async await syntax
await db.loadDatabaseAsync({});
// db is now ready to use
IndexedDBAdapter
If the database is not found.
If the database is not decrypted successfully.
If the database is not deserialized successfully.
Saves a serialized db to the catalog.
// SAVE : will save App/Key/Val as 'finance'/'test'/{serializedDb}
var idbAdapter = new SylvieIndexedAdapter('finance');
var db = new loki('test', { adapter: idbAdapter });
var coll = db.addCollection('testColl');
coll.insert({test: 'val'});
db.saveDatabase(); // could pass callback if needed for async complete
the name to give the serialized database within the catalog.
the serialized db string to save.
Optional
callback: ((err: Error | { (Optional) callback passed obj.success with true or false
Generated using TypeDoc
Loki/Sylvie encrypted persistence adapter class for indexedDb. This class fulfills abstract adapter interface which can be applied to other storage methods. Utilizes the included SylvieCatalog app/key/value database for actual database persistence. IndexedDb storage is provided per-domain, so we implement app/key/value database to allow separate contexts for separate apps within a domain.
Example