database-js-localstorage
v1.0.2
Published
Database driver that uses localstorage as a table storage mechanism
Downloads
4
Maintainers
Readme
database-js-localstorage
Database-js interface for Web Browser Local Storage
About
Database-js-localstorage is a database-js driver which uses the web browser local storage as the backend. It supports table creation, selects, inserts, deletes, and updates. Selects can use inner, left and right joins. Outer joins are not yet supported by the SQL parser. It supports schemas, the default schema is called "public".
Database-js-localstorage includes a very basic localstorage implementation for NodeJS. It saves to and reads from a file called "localstorage.json";
Install
npm install database-js database-js-localstorage
Usage:
var Connection = require('database-js').Connection;
(async () => {
let connection, statement, rows;
connection = new Connection('localstorage:///[database-name]');
try {
statement = await connection.prepareStatement("SELECT * FROM users WHERE username = ?");
rows = await statement.query('dduck');
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();
In the browser, you have to load the database-js-localstorage driver yourself and pass it to the Connection class:
var Connection = require('database-js').Connection;
var Driver = require('database-js-localstorage');
(async () => {
let connection, statement, rows;
connection = new Connection('localstorage:///[database-name]', Driver);
try {
statement = await connection.prepareStatement("SELECT * FROM users WHERE username = ?");
rows = await statement.query('dduck');
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();
License
MIT (c) mlaanderson