Skip to content

Examples JSON Connection

Thiago Delgado Pinto edited this page Feb 23, 2018 · 2 revisions

The JSON file driver connects to a local JSON file. It does not support transactions.

Connection URL

json:///file_path

Usage

var Connection = require('database-js2').Connection;

(async () => {
    let connection, statement, rows;
    connection = new Database('json:///test.json');
    
    try {
        statement = await connection.prepareStatement("SELECT * WHERE user_name = ?");
        rows = await statement.query('not_so_secret_user');
        console.log(rows);
    } catch (error) {
        console.log(error);
    } finally {
        await connection.close();
    }
})();

See more on Basic Usage

See Advanced Usage