JSPM

json-sql-query

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q30434F
  • License MIT

Use CRUD operations on JSON with SQL queries.

Package Exports

  • json-sql-query

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-sql-query) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSON SQL Query

Use CRUD operations on JSON with SQL queries.

Installing

$ npm i --save json-sql-query

Note: This library is very new and does not support most of the statements

Example

const { Database } = require("json-sql-query");

// file based
const db = new Database("./database.json");

// in-memory
const db = new Database(":memory:");

// creating a table
db.prepare(`CREATE TABLE IF NOT EXISTS "DEMO" ("key" TEXT, "value" TEXT)`).run();

// inserting data
db.prepare(`INSERT INTO "DEMO" ("key","value") VALUES ("test_key", "test_value")`).run();

// fetching data
db.prepare(`SELECT * FROM "DEMO"`).run().parse();

// fetching data in limit
db.prepare(`SELECT * FROM "DEMO" LIMIT 3`).run().parse(); // returns 3 items if available

// update existing data
db.prepare(`UPDATE "DEMO" SET "value" = "test data" WHERE "key" = "test_key"`).run()

// delete specific item
db.prepare(`DELETE FROM "DEMO" WHERE "key" = "test_key"`).run();

// drop a table
db.prepare(`DROP TABLE "DEMO"`).run();