Socket
Socket
Sign inDemoInstall

database-js-json

Package Overview
Dependencies
1
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    database-js-json

Database-js driver for JSON files


Version published
Weekly downloads
22
decreased by-24.14%
Maintainers
1
Install size
432 kB
Created
Weekly downloads
 

Readme

Source

database-js-json

A database-js driver for JSON files.

About

This is a wrapper around the jl-sql-api, intended to be used with database-js for handling JSON files.

Our releases adopt Semantic Versioning.

Install

npm install database-js-json

Basic Usage

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

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

Basic Options

Options can be passed as arguments to the database connection string, in URL-format.

  • charset: defines the charset (encoding) used to handle the JSON file

    • Defaults to utf-8
    • Example: const connection = new Database( 'json:///test.json?charset=utf-16' );
    • Available in database-js-json version 1.0.0 or later
  • checkOnConnect: whether it should check if the file exists when connecting to it

    • Defaults to true
    • Example: const connection = new Database( 'json:///test.json?checkOnConnect=false' );
    • Accepts false, no or 0 as false
    • Available in database-js-json version 1.1.0 or later

Additional Options

Options from jl-sql-api can also be passed as arguments to the database connection.

Example: { tmpDir: "/path/to/dir" }

const connection = new Database( 'json:///test.json?tmpDir=path/to/dir' );

When an option that belongs to a group is informed, it must have a dot.

Example: { tmpDir: "/path/to/dir", sortOptions: { inMemoryBufferSize: 32000 } }

const connection = new Database( 'json:///test.json?tmpDir=path/to/dir&sortOptions.inMemoryBufferSize=32000' );

License

MIT (c) thiagodp

Keywords

FAQs

Last updated on 30 Apr 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc