Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qiao.indexeddb.js

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qiao.indexeddb.js

indexeddb tools

  • 0.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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

  1. 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

  1. add sync
  2. clear sync
  3. del db sync
  4. del sync
  5. get sync
  6. list db sync
  7. put sync
  8. save sync

0.0.5.20200630

  1. list db
  2. ncu

0.0.4.20200609

  1. del log

0.0.3.20200515

  1. tx --> db
  2. indexeddb add sync

0.0.2.20200514

  1. open db
  2. del db
  3. create table
  4. del table
  5. get data
  6. add data
  7. put data
  8. del data
  9. clear data
  10. add readme
  11. save data

0.0.1.20200513

  1. init project

Keywords

FAQs

Package last updated on 31 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc