{"id":18562468,"url":"https://github.com/replit/database-node","last_synced_at":"2025-04-13T08:26:19.581Z","repository":{"id":40537511,"uuid":"285659038","full_name":"replit/database-node","owner":"replit","description":"Node.js client for Replit Database","archived":false,"fork":false,"pushed_at":"2024-08-01T09:46:14.000Z","size":67,"stargazers_count":42,"open_issues_count":0,"forks_count":27,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-27T00:11:29.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.replit.com/hosting/databases/replit-database","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mrlapizgithub/repl.it-db","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/replit.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":"2020-08-06T19:53:44.000Z","updated_at":"2025-03-05T13:19:02.000Z","dependencies_parsed_at":"2024-04-15T20:37:33.246Z","dependency_job_id":"ab99470d-b20a-4c50-b7bf-6c71f2043cb1","html_url":"https://github.com/replit/database-node","commit_stats":{"total_commits":56,"total_committers":11,"mean_commits":5.090909090909091,"dds":0.5714285714285714,"last_synced_commit":"dd0b555013f15886cf04a42606d62c8b7b0cf3f8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fdatabase-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fdatabase-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fdatabase-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fdatabase-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replit","download_url":"https://codeload.github.com/replit/database-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248682654,"owners_count":21144820,"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":[],"created_at":"2024-11-06T22:09:51.666Z","updated_at":"2025-04-13T08:26:19.554Z","avatar_url":"https://github.com/replit.png","language":"TypeScript","readme":"# Replit Database Client\n[![Run on Repl.it](https://img.shields.io/badge/run-on_Replit-f26208?logo=replit)](https://replit.com/github/replit/database-node) [![npm: @replit/database](https://img.shields.io/npm/v/%40replit%2Fdatabase)](https://www.npmjs.com/package/@replit/database)\n\nThe Replit Database client is a simple way to use [Replit Database](https://docs.replit.com/hosting/databases/replit-database) in your Node.js repls. The client expects to run within a Replit managed server context. Use this library in servers or other applications that execute on a Replit server, rather than in your user's browser.\n\n## Installation\nInstall the TypeScript Library with\n```sh\nnpm install @replit/database\n```\n\nThis library supports [Bun](https://replit.com/@replit/Bun?v=1), [Deno](https://replit.com/@replit/Deno?v=1), and [Node.js](https://replit.com/@replit/Nodejs?v=1) (Node versions 18+ or any Node version [polyfilled with the fetch API](https://github.com/node-fetch/node-fetch#providing-global-access)).\n\n\n## Quickstart\n```typescript\nimport Client from \"@replit/database\";\n\nconst client = new Client();\nawait client.set(\"key\", \"value\");\nlet value = await client.get(\"key\");\n\nconsole.log(value); // { ok: true, value: \"value\" }\n\n```\n\n## Docs\n\nInitiate a new database client:\n```typescript\nimport Client from \"@replit/database\";\n\n/**\n * Initiates Class.\n * @param {String} dbUrl Custom database URL\n */\nnew Client()\n```\n\nRetrieve a value for a key from the database:\n```typescript\n/**\n * Gets a key\n * @param {String} key Key\n * @param {boolean} [options.raw=false] Makes it so that we return the raw string value. Default is false.\n * @returns Promise\u003cOkResult\u003cany\u003e | ErrResult\u003cRequestError\u003e\u003e\n */\nconst value = await client.get(key, /* options?: {raw: boolean} */)\nconsole.log(value)\n// { ok: true, value: \"value\" } | { ok: false, error: RequestError }\n```\n\nSets a value for a key in the database:\n```typescript\n/**\n * Sets a key\n * @param {String} key Key\n * @param {any} value Value\n */\nawait client.set(key, value)\n```\n\nDeletes a key from the database:\n```typescript\n/**\n * Deletes a key\n * @param {String} key Key\n */\nconst result = await client.delete(key)\nconsole.log(result.ok) // boolean\n```\n\nLists all keys starting with the provided prefix:\n```typescript\n/**\n * List key starting with a prefix if provided. Otherwise list all keys.\n * @param {String} prefix The prefix to filter by.\n */\nconst keys = await client.list(\"prefix-\")\nconsole.log(keys) // { ok: true, value: [...] } | { ok: false, error: RequestError }\n```\n\nClears the database:\n```typescript\n/**\n * Clears the database.\n * @returns a Promise containing this\n */\nawait client.empty()\n```\n\nGets all records in the database:\n```typescript\n/**\n * Get all key/value pairs and return as an object\n * @param {boolean} [options.raw=false] Makes it so that we return the raw\n * string value for each key. Default is false.\n */\nconst records = await client.getAll(/* options?: {raw: boolean} */)\n```\n\nSets multiple key value pairs:\n```typescript\n/**\n * Sets multiple keys from an object.\n * @param {Object} obj The object.\n */\nawait client.setMultiple({keyOne: \"valueOne\", keyTwo: \"valueTwo\"})\n```\n\nDeletes multiple keys from the database:\n```typescript\n/**\n * Delete multiple entries by key.\n * @param {Array\u003cstring\u003e} args Keys\n */\nawait client.deleteMultiple(['keyOne', 'keyTwo'])\n```\n\n\n## Tests\n```sh\nnpm i\nnpm run test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fdatabase-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplit%2Fdatabase-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fdatabase-node/lists"}