database-js-localstorage

1.0.2 • Public • Published

database-js-localstorage

Build Status

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

/database-js-localstorage/

    Package Sidebar

    Install

    npm i database-js-localstorage

    Weekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    11.9 kB

    Total Files

    7

    Last publish

    Collaborators

    • manderson10