{"id":15305812,"url":"https://github.com/ajayos/nodedb","last_synced_at":"2026-02-14T04:05:08.029Z","repository":{"id":158752412,"uuid":"634243905","full_name":"Ajayos/nodedb","owner":"Ajayos","description":"DATABASE using nodejs","archived":false,"fork":false,"pushed_at":"2023-08-20T13:25:49.000Z","size":64,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T09:46:50.636Z","etag":null,"topics":["ajay","ajayos","database","db","sql","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ajayos.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Ajayos"}},"created_at":"2023-04-29T14:04:34.000Z","updated_at":"2024-11-08T11:49:00.000Z","dependencies_parsed_at":"2025-02-01T20:42:41.554Z","dependency_job_id":"b4753095-dca0-43f8-a53a-a83a884d9fb3","html_url":"https://github.com/Ajayos/nodedb","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajayos%2Fnodedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajayos%2Fnodedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajayos%2Fnodedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajayos%2Fnodedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ajayos","download_url":"https://codeload.github.com/Ajayos/nodedb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245892252,"owners_count":20689466,"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":["ajay","ajayos","database","db","sql","sqlite3"],"created_at":"2024-10-01T08:03:30.044Z","updated_at":"2026-02-14T04:05:07.973Z","avatar_url":"https://github.com/Ajayos.png","language":"JavaScript","funding_links":["https://github.com/sponsors/Ajayos"],"categories":[],"sub_categories":[],"readme":"# NodeDB\r\n\r\nNodeDB is a simple key-value store for Node.js, built on top of SQLite.\r\n\r\n## Installation\r\n\r\nYou can install NodeDB using npm:\r\n\r\n```sh\r\nnpm install @ajayos/nodedb\r\n```\r\n\r\n## Setup\r\n\r\n1. Install NodeDB using npm:\r\n\r\n```sh\r\nnpm install @ajayos/nodedb\r\n```\r\n\r\n2. Import and create an instance of the DB class with a custom database file path:\r\n\r\n```javascript\r\nconst DB = require('@ajayos/nodedb');\r\nconst customDBPath = '/path/to/custom/database/file.db';\r\nconst nodedb = new DB(customDBPath);\r\n```\r\n\r\n3. Use the available functions to interact with the database, as demonstrated in the examples below.\r\n\r\n## Project Description\r\n\r\nNodeDB provides an efficient way to manage key-value data in your Node.js applications by leveraging the power of SQLite. It offers a lightweight and embedded database solution suitable for small to medium-sized projects. Whether you need to store user profiles, configuration settings, or any other structured data, NodeDB simplifies the process by providing easy-to-use functions for storing, retrieving, and deleting data.\r\n\r\n## Functions and Usage\r\n\r\n### `setDB(tableName, rowName, data)`\r\n\r\nInserts or updates a row in the specified table with the specified key and data.\r\n\r\n#### Example Usage:\r\n\r\n```javascript\r\nawait nodedb.setDB('users', 'ajay', { name: 'Ajay o s', age: 20 });\r\n```\r\n\r\n### `getDB(tableName, rowName)`\r\n\r\nRetrieves a row from the specified table with the specified key, or all rows if no key is specified.\r\n\r\n#### Example Usage:\r\n\r\n```javascript\r\nconst ajay = await nodedb.getDB('users', 'ajay');\r\nconsole.log(ajay); // { name: 'Ajay o s', age: 20 }\r\n```\r\n\r\n#### Example Usage (All Rows):\r\n\r\n```javascript\r\nconst allUsers = await nodedb.getDB('users');\r\nconsole.log(allUsers); // [ { rowName: 'ajay', data: { name: 'Ajay o s', age: 20 } }, ... ]\r\n```\r\n\r\n### `deleteDB(tableName, rowName)`\r\n\r\nDeletes a row from the specified table with the specified key, or the entire table if no key is specified.\r\n\r\n#### Example Usage:\r\n\r\n```javascript\r\nawait nodedb.deleteDB('users', 'ajay');\r\n```\r\n\r\n#### Example Usage (Delete Table):\r\n\r\n```javascript\r\nawait nodedb.deleteDB('users');\r\n```\r\n\r\n### `setDATA(tableName, rowName, data: any)`\r\n\r\nSimilar to `setDB`, but stores data without JSON stringifying it.\r\n\r\n#### Example Usage:\r\n\r\n```javascript\r\nawait nodedb.setDATA('metadata', 'version', 1.2);\r\n```\r\n\r\n### `getDATA(tableName, rowName)`\r\n\r\nSimilar to `getDB`, but retrieves data without JSON parsing it.\r\n\r\n#### Example Usage:\r\n\r\n```javascript\r\nconst version = await nodedb.getDATA('metadata', 'version');\r\nconsole.log(version); // 1.2\r\n```\r\n\r\n#### Example Usage (All Rows):\r\n\r\n```javascript\r\nconst allVersions = await nodedb.getDATA('metadata');\r\nconsole.log(allVersions); // [ { rowName: 'version', data: 1.2 }, ... ]\r\n```\r\n\r\n### `deleteDATA(tableName, rowName)`\r\n\r\nSimilar to `deleteDB`, but deletes data without JSON parsing it.\r\n\r\n#### Example Usage:\r\n\r\n```javascript\r\nawait nodedb.deleteDATA('metadata', 'version');\r\n```\r\n\r\n#### Example Usage (Delete Table):\r\n\r\n```javascript\r\nawait nodedb.deleteDATA('metadata');\r\n```\r\n\r\nExample\r\nHere's a complete example of how to use NodeDB to interact with a database:\r\n\r\n```javascript\r\nconst DB = require('@ajayos/nodedb');\r\n\r\n// Define a custom database file path\r\nconst customDBPath = 'mydatabase.sql';\r\n\r\n// Create an instance of the DB class\r\nconst nodedb = new DB(customDBPath);\r\n\r\nasync function main() {\r\n  // Set data using setDB\r\n  await nodedb.setDB('users', 'ajay', { name: 'Ajay o s', age: 20 });\r\n\r\n  // Get data using getDB\r\n  const ajay = await nodedb.getDB('users', 'ajay');\r\n  console.log('Retrieved Data:', ajay);\r\n\r\n  // Delete a specific row using deleteDB\r\n  await nodedb.deleteDB('users', 'ajay');\r\n}\r\n\r\n// Run the main function\r\nmain().catch((error) =\u003e {\r\n  console.error('An error occurred:', error);\r\n});\r\n```\r\n\r\n## Note\r\n\r\nFor functions like `deleteDB` and `deleteDATA`, if you provide only the `tableName`, the entire table will be deleted. To delete a specific row, provide both `tableName` and `rowName`.\r\n\r\n## License\r\n\r\nNodeDB is licensed under the Apache License 2.0. See the [LICENSE](/LICENSE) file for details.\r\n\r\n## Repository\r\n\r\nYou can find the repository for NodeDB on GitHub at [https://github.com/Ajayos/nodedb](https://github.com/Ajayos/nodedb)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajayos%2Fnodedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajayos%2Fnodedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajayos%2Fnodedb/lists"}