Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cesiumlabs/json-sql-query
Use CRUD operations on JSON with SQL queries.
https://github.com/cesiumlabs/json-sql-query
database json json-sql sql
Last synced: about 2 months ago
JSON representation
Use CRUD operations on JSON with SQL queries.
- Host: GitHub
- URL: https://github.com/cesiumlabs/json-sql-query
- Owner: CesiumLabs
- Created: 2021-05-06T02:52:44.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-05-06T16:09:19.000Z (over 3 years ago)
- Last Synced: 2024-10-28T16:59:59.289Z (3 months ago)
- Topics: database, json, json-sql, sql
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/json-sql-query
- Size: 17.6 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON SQL Query
Use **CRUD** operations on **JSON** with **SQL** queries.# Installing
```sh
$ npm i --save json-sql-query
```> Note: This library is very new and does not support most of the statements
# Example
```js
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();
```