qiao.indexeddb.js
documentation
- indexeddb, https://wangdoc.com/javascript/bom/indexeddb.html
api
openDB
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
try{
var databaseName = 'db_test';
var version = 1;
var db = await qdb.openDB(databaseName, version);
console.log(db);
}catch(e){
console.log(e);
}
};
test();
listDB
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
try{
var dbs = await qdb.listDB();
console.log(dbs);
}catch(e){
console.log(e);
}
};
test();
delDB
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
try{
var databaseName = 'db_test';
await qdb.delDB(databaseName);
}catch(e){
console.log(e);
}
};
test();
createTable
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
var databaseName = 'db_test';
var version = 1;
var tables = [{
name : 't_test1',
key : 'id',
index : {
name : 'name',
unique : false
}
},{
name : 't_test2',
key : 'auto',
index : {
name : 'email',
unique : true
}
}];
try{
var db = await qdb.openDB(databaseName, version);
var res = qdb.createTable(db, tables);
console.log(res);
}catch(e){
console.log(e);
}
};
test();
delTable
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
try{
var databaseName = 'db_test';
var version = 2;
var db = await qdb.openDB(databaseName, version);
qdb.delTable(db, 't_test2');
}catch(e){
console.log(e);
}
};
test();
save
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
try{
var databaseName = 'db_test';
var version = 2;
var db = await qdb.openDB(databaseName, version);
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
await qdb.save(db, tableName, data);
data.name = '1';
await qdb.save(db, tableName, data);
}catch(e){
console.log(e);
}
};
test();
get
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
var databaseName = 'db_test';
var tableName = 't_test1';
var version = 2;
try{
var db = await qdb.openDB(databaseName, version);
var s = await qdb.get(db, tableName, 1);
console.log(s);
}catch(e){
console.log(e);
}
};
test();
del
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
var databaseName = 'db_test';
var tableName = 't_test1';
var version = 2;
try{
var db = await qdb.openDB(databaseName, version);
await qdb.del(db, tableName, 2);
}catch(e){
console.log(e);
}
};
test();
clear
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
var databaseName = 'db_test';
var tableName = 't_test1';
var version = 2;
try{
var db = await qdb.openDB(databaseName, version);
await qdb.clear(db, tableName);
}catch(e){
console.log(e);
}
};
test();
version
0.0.7.20201023
- export sync
0.0.6.20200731
- add sync
- clear sync
- del db sync
- del sync
- get sync
- list db sync
- put sync
- save sync
0.0.5.20200630
- list db
- ncu
0.0.4.20200609
- del log
0.0.3.20200515
- tx --> db
- indexeddb add sync
0.0.2.20200514
- open db
- del db
- create table
- del table
- get data
- add data
- put data
- del data
- clear data
- add readme
- save data
0.0.1.20200513
- init project