{"id":21531930,"url":"https://github.com/matrixai/js-db","last_synced_at":"2025-04-10T00:29:02.199Z","repository":{"id":38287577,"uuid":"407114709","full_name":"MatrixAI/js-db","owner":"MatrixAI","description":"Key-Value DB for TypeScript and JavaScript Applications","archived":false,"fork":false,"pushed_at":"2023-11-09T00:32:29.000Z","size":2835,"stargazers_count":5,"open_issues_count":14,"forks_count":0,"subscribers_count":5,"default_branch":"staging","last_synced_at":"2024-10-31T13:27:03.492Z","etag":null,"topics":["database","key-value-database","rocksdb"],"latest_commit_sha":null,"homepage":"https://polykey.com","language":"TypeScript","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/MatrixAI.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}},"created_at":"2021-09-16T10:07:00.000Z","updated_at":"2023-09-04T14:23:21.000Z","dependencies_parsed_at":"2023-11-09T00:33:52.485Z","dependency_job_id":null,"html_url":"https://github.com/MatrixAI/js-db","commit_stats":{"total_commits":165,"total_committers":4,"mean_commits":41.25,"dds":0.08484848484848484,"last_synced_commit":"82f6b31cc609f02d1282d3c6c351f75a3e1de22e"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatrixAI","download_url":"https://codeload.github.com/MatrixAI/js-db/tar.gz/refs/heads/staging","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226116124,"owners_count":17575948,"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","key-value-database","rocksdb"],"created_at":"2024-11-24T02:18:13.014Z","updated_at":"2025-04-10T00:29:02.190Z","avatar_url":"https://github.com/MatrixAI.png","language":"TypeScript","readme":"# js-db\n\nDB is library managing key value state for MatrixAI's JavaScript/TypeScript applications.\n\nThis forks classic-level's C++ binding code around LevelDB 1.20. Differences from classic-level:\n\n* Uses TypeScript from ground-up\n* Supports Snapshot-Isolation based transactions via `DBTransaction`\n* API supports \"key paths\" which can be used to manipulate \"levels\" of nested keys\n* Value encryption (key-encryption is not supported yet) - requires additional work with block-encryption\n* Uses RocksDB\n\n## Installation\n\n```sh\nnpm install --save @matrixai/db\n```\n\n## Usage\n\n```ts\nimport { DB } from '@matrixai/db';\n\nasync function main () {\n\n  const key = Buffer.from([\n    0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,\n    0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,\n  ]);\n\n  const encrypt = async (\n    key: ArrayBuffer,\n    plainText: ArrayBuffer\n  ): Promise\u003cArrayBuffer\u003e =\u003e {\n    return plainText;\n  };\n\n  const decrypt = async (\n    key: ArrayBuffer,\n    cipherText: ArrayBuffer\n  ): Promise\u003cArrayBuffer | undefined\u003e =\u003e {\n    return cipherText;\n  }\n\n  const db = await DB.createDB({\n    dbPath: './tmp/db',\n    crypto: {\n      key,\n      ops: { encrypt, decrypt },\n    },\n    fresh: true,\n  });\n\n  await db.put(['level', Buffer.from([0x30, 0x30]), 'a'], 'value');\n  await db.put(['level', Buffer.from([0x30, 0x31]), 'b'], 'value');\n  await db.put(['level', Buffer.from([0x30, 0x32]), 'c'], 'value');\n  await db.put(['level', Buffer.from([0x30, 0x33]), 'c'], 'value');\n\n  console.log(await db.get(['level', Buffer.from([0x30, 0x32]), 'c']));\n\n  await db.del(['level', Buffer.from([0x30, 0x32]), 'c']);\n\n  for await (const [kP, v] of db.iterator(\n    ['level'],\n    {\n      lt: [Buffer.from([0x30, 0x32]), ''],\n    })) {\n    console.log(kP, v);\n  }\n\n  await db.stop();\n}\n\nmain();\n```\n\nIf you created the `DB` with a `crypto` object, then upon restarting the `DB`, you must pass in the same `crypto` object.\n\n## Development\n\nThis project uses Git submodules to bring in rocksdb. **Make sure to clone recursively.**\n\nIf you already cloned, run this:\n\n```sh\ngit submodule update --init --recursive\n```\n\nRun `nix develop`, and once you're inside, you can use:\n\n```sh\n# install (or reinstall packages from package.json)\nnpm install\n# build the dist\nnpm run build\n# run the repl (this allows you to import from ./src)\nnpm run tsx\n# run the tests\nnpm run test\n# lint the source code\nnpm run lint\n# automatically fix the source\nnpm run lintfix\n```\n\n## Benchmarks\n\n```sh\nnpm run bench\n```\n\nView benchmarks here: https://github.com/MatrixAI/js-db/blob/master/benches/results with https://raw.githack.com/\n\n### Docs Generation\n\n```sh\nnpm run docs\n```\n\nSee the docs at: https://matrixai.github.io/js-db/\n\n### Publishing\n\nPublishing is handled automatically by the staging pipeline.\n\nPrerelease:\n\n```sh\n# npm login\nnpm version prepatch --preid alpha # premajor/preminor/prepatch\ngit push --follow-tags\n```\n\nRelease:\n\n```sh\n# npm login\nnpm version patch # major/minor/patch\ngit push --follow-tags\n```\n\nManually:\n\n```sh\n# npm login\nnpm version patch # major/minor/patch\nnpm run build\nnpm publish --access public\ngit push\ngit push --tags\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixai%2Fjs-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrixai%2Fjs-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixai%2Fjs-db/lists"}