urls
homepage
https://code.insistime.com/qiao.indexeddb.js
github
https://github.com/insistime/qiao.indexeddb.js
npm
https://www.npmjs.com/package/qiao.indexeddb.js
donate
http://uikoo9.com/donate
started
install
npm install qiao.indexeddb.js
dependencies
documentation
- indexeddb, https://wangdoc.com/javascript/bom/indexeddb.html
async api
openDB
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = function(){
var databaseName = 'db_test';
var version = 1;
qdb.openDB(databaseName, version, function(db){
console.log(db);
}, function(db){
console.log(db);
});
};
test();
listDB
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = function(){
qdb.listDB(function(dbs){
console.log(dbs);
});
};
test();
delDB
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = function(){
var databaseName = 'db_test';
qdb.delDB(databaseName, function(res){
console.log(res);
});
};
test();
createTable
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
};
test();
delTable
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
qdb.delTable(db, 't_test1');
});
};
test();
add
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
qdb.add(db, tableName, data, function(r){
console.log(r);
});
});
};
test();
get
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
qdb.add(db, tableName, data, function(r){
if(!r) return;
qdb.get(db, tableName, 1, function(rr){
console.log(rr);
});
});
});
};
test();
put
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
qdb.add(db, tableName, data, function(r){
if(!r) return;
data.name = '1';
qdb.put(db, tableName, data, function(rr){
console.log(rr);
});
});
});
};
test();
save
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
qdb.save(db, tableName, 1, data, function(r){
console.log(r);
data.name = '1';
qdb.save(db, tableName, 1, data, function(rr){
console.log(rr);
});
});
});
};
test();
del
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
qdb.add(db, tableName, data, function(r){
if(!r) return;
qdb.del(db, tableName, 1, function(rr){
console.log(rr);
});
});
});
};
test();
clear
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
qdb.add(db, tableName, data, function(r){
if(!r) return;
qdb.clear(db, tableName, function(rr){
console.log(rr);
});
});
});
};
test();
sync api
listDBSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
var dbs = await qdb.listDBSync();
console.log(dbs);
};
test();
delDBSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = async function(){
var databaseName = 'db_test';
var res = await qdb.delDBSync(databaseName);
console.log(res);
};
test();
addSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, async function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
var r = await qdb.addSync(db, tableName, data);
console.log(r);
});
};
test();
getSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, async function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
var r = await qdb.addSync(db, tableName, data);
if(!r) return;
var rr = await qdb.getSync(db, tableName, 1);
console.log(rr);
});
};
test();
putSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, async function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
var r = await qdb.addSync(db, tableName, data);
if(!r) return;
var rr = await qdb.putSync(db, tableName, data);
console.log(rr);
});
};
test();
saveSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, async function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
var r = await qdb.saveSync(db, tableName, 1, data);
data.name = '1';
var rr = await qdb.saveSync(db, tableName, 1, data);
console.log(rr);
});
};
test();
delSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, async function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
var r = await qdb.addSync(db, tableName, data);
if(!r) return;
var rr = await qdb.delSync(db, tableName, 1);
console.log(rr);
});
};
test();
clearSync
'use strict';
var qdb = require('qiao.indexeddb.js');
var test = 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
}
}];
qdb.openDB(databaseName, version, function(db){
var res = qdb.createTable(db, tables);
console.log(res);
});
qdb.openDB(databaseName, version, null, async function(db){
var tableName = 't_test1';
var data = { id: 1, name: '张三', age: 24, email: 'zhangsan@example.com' };
var r = await qdb.addSync(db, tableName, data);
if(!r) return;
var rr = await qdb.clearSync(db, tableName, 1);
console.log(rr);
});
};
test();
version
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