Skip to content

honibis/simple-async-indexeddb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

simple-async-indexeddb

Javascript IndexedDb wrapper, promise based, very simple and lightweight

Usage

Create Service:

let dbService = new IndexedDbService();

Initialize service

Parameters

-databaseName: each service instance manages 1 databese -dataTables: array of objects with properties name, keyPath and index names

await dbService.init("MyDatabase", [
    { name: "DataTable1", keyPath: "id", indexes: ["name"] },
    { name: "DataTable2", keyPath: "id", indexes: ["name"] },
]);

Insert Data

await dbService.updateOrCreate("DataTable1", {id:1, name:"Name1"});

Update Data

await dbService.updateOrCreate("DataTable1", {id:1, name:"Name2"});

Update Data By Index

await dbService.updateOrCreate("DataTable1", {name:"Name2", newProp:"Some Value"});

Get By Id

Parameters

-tableName -value (id)

let data = await dbService.get("DataTable1", 1);

Get By Index

Parameters

-tableName -value -indexName

let data = await dbService.get("DataTable1", "Name2", "name");

Delete

Parameters

-tableName -value (id)

await dbService.delete("DataTable1", 1);

Delete By Index

Parameters

-tableName -value -indexName

await dbService.delete("DataTable1", "Name2", "name");

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published