{"id":19430397,"url":"https://github.com/demonicious/jql","last_synced_at":"2025-02-25T05:43:19.230Z","repository":{"id":143988378,"uuid":"187294150","full_name":"Demonicious/jql","owner":"Demonicious","description":"Module used for Creating, Managing, Writing and Reading JSON Files and use them as a Database","archived":false,"fork":false,"pushed_at":"2019-05-19T23:43:04.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-07T20:14:03.355Z","etag":null,"topics":["database","database-management","db","json","sql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Demonicious.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-17T23:48:43.000Z","updated_at":"2019-05-19T23:43:05.000Z","dependencies_parsed_at":"2023-10-13T09:43:49.443Z","dependency_job_id":"7e9ab633-a2c6-4ba4-9c01-aa6625581491","html_url":"https://github.com/Demonicious/jql","commit_stats":null,"previous_names":["mudassarislam/jql","demonicious/jql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Demonicious%2Fjql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Demonicious%2Fjql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Demonicious%2Fjql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Demonicious%2Fjql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Demonicious","download_url":"https://codeload.github.com/Demonicious/jql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240612537,"owners_count":19829027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","database-management","db","json","sql"],"created_at":"2024-11-10T14:24:47.831Z","updated_at":"2025-02-25T05:43:19.196Z","avatar_url":"https://github.com/Demonicious.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Ever wanted to use JSON as a database in an SQL-Like Environment ? Yeah me neither but still this is a thing..\n\n## 1.) Installation using NPM\n\n```\nnpm install --save demon-jql\n```\n\n## 2.) Basic Usage\n\n```javascript\nconst { Database } = require(\"demon-jql\");\nconst db = new Database(\"newDatabase\", \"./newDatabase\"); // Name and Path\n```\n\n## 3.) Creating a Table\n\n```javascript\nlet foodColumns = [\n    {\n        \"type\": \"text\",\n        \"name\": \"foodName\"\n    },\n    {\n        \"type\": \"text\",\n        \"name\": \"originCountry\"\n    }\n]\n\ndb.createTable(\"food\", foodColumns);\n\n// Expected Return:- bool : true\n```\n\n## 4.) Inserting Data into Table\n\n```javascript\nlet data = [\n    {\n        \"name\": \"Pizza\",\n        \"originCountry\": \"Italy\",\n    },\n    {\n        \"name\": \"Lahmacun\",\n        \"originCountry\": \"Turkey\"\n    }\n]\n\ndb\n.write(\"food\", data)\n.run();\n\n// Expected Return:- bool : true\n```\n\n## 5.) Reading Data from Table.\n\n```javascript\ndb\n.select(\"food\", \"*\") // Select Everything\n.run();\n\n// Expected Return: Object : { \"0\": { \"name\": \"Pizza\", \"originCountry\": \"Italy\" }, \"1\": { \"name\": \"Lahmacun\", \"originCountry\": \"Turkey\" }, \"success\": true }\n// The Return object has a property of \"success\" which is either True/False based on if data was retrieved\n\ndb\n.select(\"food\", [\"name\"]) // If Selecting Columns Specifically, They need to be placed in a StringArray[] (even for individual columns) e.g [\"name\", \"originCountry\"]\n.where({\"originCountry\": \"Turkey\"}) // Where Method takes in a Object as parameter.\n.run();\n\n// Expected Return:- Object : { \"0\" : {\"name\": \"Pizza\" }, \"success\": true }\n```\n\n## 6.) Updating Pre-existing Data.\n\n```javascript\n// Warning: Using .update() without .where() will Update the entire table.\n\ndb\n.update(\"food\", {\"name\": \"Kebab\"}) // Update method takes in the Table name and Object as parameters.\n.where({\"originCountry\": \"Turkey\"})\n.run();\n\n// Expected Return:- bool : true\n```\n\n## 7.) Using Auto Increments\n\n```javascript\n\ndb.createTable(\"users\", [\n    {\n        \"type\": \"number\",\n        \"name\": \"id\"\n    },\n    {\n        \"type\": \"text\",\n        \"name\": \"username\"\n    }\n])\n\n// Expected Return:- bool : true\n\n// If writing a Single row, It still needs to be placed inside an Array[]\ndb.write(\"users\", [\n    {\n        \"id\": db.nextID(),\n        \"name\": \"Demonicious\"\n    }\n]).run();\n\n// Expected Return:- bool : true\n```\n\n## 8.) An Example\n\n```javascript\nconst { Database } = require(\"demon-jql\");\nconst db = new Database(\"db2\", \"./db2\");\n\n// Creating a New Table\n// .run() method isn't used here.\ndb.createTable(\"someTable\", [\n    {\n        \"type\": \"number\",\n        \"name\": \"id\"\n    },\n    {\n        \"type\": \"text\",\n        \"name\": \"name\"\n    }\n]);\n\n// Filling the table with Data\ndb.write(\"someTable\", [\n    {\n        \"id\": db.nextID(),\n        \"name\": \"Demonicious1\"\n    },\n    {\n        \"id\": db.nextID(),\n        \"name\": \"Demonicious2\"\n    },\n    {\n        \"id\": db.nextID(),\n        \"name\": \"Demonicious3\"\n    },\n    {\n        \"id\": db.nextID(),\n        \"name\": \"Demonicious4\"\n    },\n    {\n        \"id\": db.nextID(),\n        \"name\": \"Demonicious5\"\n    },\n    {\n        \"id\": db.nextID(),\n        \"name\": \"Demonicious6\"\n    }\n]).run();\n\n// Updating a Row\n// .where() is optional but without it, it will rewwrite the entire table.\ndb.update(\"someTable\", {\n    \"name\": \"DemoniciousSIX\"\n}).where({\n    \"id\": \"5\"\n}).run();\n\n// Removing a Row\ndb.removeRow(\"someTable\").where({\n    \"id\":\"4\"\n}).run();\n\n// Retrieving single column\n// .where() is optional in Select\nvar data = db.select(\"someTable\", [\n    \"name\"\n]).where({\n    \"id\": \"5\"\n}).run();\n\nif (data.success) {\n    console.log(\"Name Fetched From Table:\", data[0][\"name\"]);\n}\n\n// Retrieving Multiple Columns\ndata = db.select(\"someTable\", [\n    \"id\",\n    \"name\"\n]).where({\n    \"id\": \"5\"\n}).run();\n\nif (data.success) {\n    console.log(data);\n}\n\n// Retrieving Everything\nvar data = db.select(\"someTable\", \"*\").where({\n    \"id\": \"5\"\n}).run();\n\nif (data.success) {\n    console.log(data);\n}\n\n// Removing a Table Entirely\n// .run() isn't used here.\n// I removed this table just to show it can be done.\ndb.removeTable(\"someTable\");\n\n// Just a simple test method()\ndb.test()\n// Returns True if DB is working, otherwise False\n```\n\nI plan to Make a lot of Optimizations and add more features (making it more sql-like)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemonicious%2Fjql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemonicious%2Fjql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemonicious%2Fjql/lists"}