{"id":21693326,"url":"https://github.com/lullaby6/jnbase","last_synced_at":"2025-12-31T00:05:11.086Z","repository":{"id":196392495,"uuid":"696041224","full_name":"lullaby6/jnbase","owner":"lullaby6","description":"NPM Package - Manipulates json files easily for use as lightweight databases","archived":false,"fork":false,"pushed_at":"2023-09-25T20:48:33.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T18:06:04.738Z","etag":null,"topics":["data-base","database","db","javascript","js","js-package","json","json-database","json-db","node","nosql","npm","npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/jnbase","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lullaby6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-09-25T00:32:59.000Z","updated_at":"2024-09-07T04:37:13.000Z","dependencies_parsed_at":"2023-09-29T17:17:23.147Z","dependency_job_id":null,"html_url":"https://github.com/lullaby6/jnbase","commit_stats":null,"previous_names":["lullaby6/jnbase","lullaby6/jbase"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fjnbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fjnbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fjnbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fjnbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lullaby6","download_url":"https://codeload.github.com/lullaby6/jnbase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243769963,"owners_count":20345217,"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":["data-base","database","db","javascript","js","js-package","json","json-database","json-db","node","nosql","npm","npm-package"],"created_at":"2024-11-25T18:19:29.108Z","updated_at":"2025-12-31T00:05:11.078Z","avatar_url":"https://github.com/lullaby6.png","language":"JavaScript","readme":"# JNBase\n\nJNBase is a simple and lightweight and asynchronous file-based JSON database. It features in-memory caching, atomic writes to prevent data corruption, and Mutex locking to ensure concurrency safety.\n\n## Installation\n\n### NPM\n\n```bash\nnpm i jnbase\n```\n\n### Import\n\n#### CommonJS\n\n```js\nconst { createData, getDataById } = require(\"jnbase\");\n```\n\n#### ModuleJS\n\n```js\nimport { createData, getDataById } from \"jnbase\";\n```\n\n## Usage\n\n```js\nconst {\n\tcreateKey,\n\tcreateData,\n\tgetDataByObject,\n\tupdateDataById,\n\tdeleteDataById,\n} = require(\"jnbase\");\n\n(async () =\u003e {\n\tawait createKey(\"users\");\n\n\tawait createData(\"users\", {\n\t\tname: \"Alice\",\n\t\tage: 25,\n\t\trole: \"admin\",\n\t});\n\n\tconst users = await getDataByObject(\"users\", {\n\t\tname: \"Alice\",\n\t});\n\n\tconst user = users[0];\n\n\tconsole.log(user);\n\n\tawait updateDataById(\"users\", user.id, {\n\t\tage: 26,\n\t});\n\n\tawait deleteDataById(\"users\", user.id);\n})();\n```\n\n## API\n\n| Method               | Description                                                                         | Parameters                                               | Returns                      |\n| -------------------- | ----------------------------------------------------------------------------------- | -------------------------------------------------------- | ---------------------------- |\n| `createKey`          | Creates a new empty array for a key if it does not exist.                           | `key` (string)                                           | `Promise\u003cvoid\u003e`              |\n| `getKeyData`         | Retrieves all data associated with a key.                                           | `key` (string)                                           | `Promise\u003cArray\u003e`             |\n| `setKeyData`         | Overwrites all data for a specific key.                                             | `key` (string), `value` (array)                          | `Promise\u003cvoid\u003e`              |\n| `renameKey`          | Renames an existing key.                                                            | `key` (string), `newKey` (string)                        | `Promise\u003cvoid\u003e`              |\n| `deleteKey`          | Deletes a key and all its data.                                                     | `key` (string)                                           | `Promise\u003cvoid\u003e`              |\n| `clearKeyData`       | Empties the array for a specific key.                                               | `key` (string)                                           | `Promise\u003cvoid\u003e`              |\n| `createData`         | Adds a new object to a key array. Generates UUID if missing. Checks for duplicates. | `key` (string), `data` (object)                          | `Promise\u003cvoid\u003e`              |\n| `createMultipleData` | Adds multiple objects to a key array efficiently.                                   | `key` (string), `dataList` (array)                       | `Promise\u003cvoid\u003e`              |\n| `getDataById`        | Retrieves a specific item by its ID.                                                | `key` (string), `id` (string)                            | `Promise\u003cObject, undefined\u003e` |\n| `getDataByObject`    | Retrieves items matching a specific set of key-value pairs.                         | `key` (string), `condition` (object)                     | `Promise\u003cArray\u003e`             |\n| `updateDataById`     | Updates fields of an item identified by ID.                                         | `key` (string), `id` (string), `newData` (object)        | `Promise\u003cboolean\u003e`           |\n| `updateDataByObject` | Updates items matching a condition.                                                 | `key` (string), `condition` (object), `newData` (object) | `Promise\u003cnumber\u003e`            |\n| `deleteDataById`     | Removes an item by its ID.                                                          | `key` (string), `id` (string)                            | `Promise\u003cboolean\u003e`           |\n| `deleteDataByObject` | Removes items matching a condition.                                                 | `key` (string), `condition` (object)                     | `Promise\u003cboolean\u003e`           |\n| `hasDataById`        | Checks if an item with the given ID exists.                                         | `key` (string), `id` (string)                            | `Promise\u003cboolean\u003e`           |\n| `hasDataByObject`    | Checks if any item matches the condition.                                           | `key` (string), `condition` (object)                     | `Promise\u003cboolean\u003e`           |\n| `getJsonData`        | Returns the entire database object from memory.                                     | None                                                     | `Promise\u003cObject\u003e`            |\n| `setJsonData`        | Replaces the entire database. Use with caution.                                     | `jsonData` (object)                                      | `Promise\u003cvoid\u003e`              |\n\n## License\n\n-   [MIT](https://github.com/lullaby6/jnbase/blob/main/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flullaby6%2Fjnbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flullaby6%2Fjnbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flullaby6%2Fjnbase/lists"}