{"id":23763475,"url":"https://github.com/qgisk/kv","last_synced_at":"2025-08-29T06:23:29.068Z","repository":{"id":101300136,"uuid":"440598527","full_name":"QGIsK/kv","owner":"QGIsK","description":"Simple kv-store for mongodb","archived":false,"fork":false,"pushed_at":"2021-12-29T19:35:45.000Z","size":325,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-08T21:23:04.405Z","etag":null,"topics":["keyvalue","keyvaluestore","kv","kv-store","mongodb"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/QGIsK.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2021-12-21T17:27:40.000Z","updated_at":"2023-03-07T07:18:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"78092c64-8b98-44c5-92bf-bb61ca8fe87a","html_url":"https://github.com/QGIsK/kv","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":"QGIsK/lib-ts-starter","purl":"pkg:github/QGIsK/kv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QGIsK%2Fkv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QGIsK%2Fkv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QGIsK%2Fkv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QGIsK%2Fkv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QGIsK","download_url":"https://codeload.github.com/QGIsK/kv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QGIsK%2Fkv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272641242,"owners_count":24968802,"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","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["keyvalue","keyvaluestore","kv","kv-store","mongodb"],"created_at":"2024-12-31T22:12:32.096Z","updated_at":"2025-08-29T06:23:29.055Z","avatar_url":"https://github.com/QGIsK.png","language":"TypeScript","readme":"# KV\n\n\u003cspan class=\"badge-npmversion\"\u003e\u003ca href=\"https://www.npmjs.com/package/@qgisk/kv\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@qgisk/kv.svg\" alt=\"NPM version\"/\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-npmdownloads\"\u003e\u003ca href=\"https://www.npmjs.org/package/@qgisk/kv\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@qgisk/kv.svg\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n## About\n\nKV is a simple MongoDB based key value store.\n\nIf you're looking for a key value library that supports more than just MongoDB checkout [keyv](https://github.com/jaredwray/keyv)\n\nIf you're looking for a CLI checkout [this](https://github.com/qgisk/kv-cli)\n\n## Installation\n\n```bash\nnpm i @qgisk/kv mongoose\n```\n\n## Example\n\nSimple quick start example\n\n```javascript\nimport {KV} from '@qgisk/kv';\n// or for commonjs\nconst {KV} = require('@qgisk/kv');\n\n// First value is the mongodb uri, the second is your namespace.\n// db uri defaults to mongodb://localhost:27017/kv\n// namespace defaults to 'kv'\nconst kv = new KV('uri', 'namespace');\n\nawait kv.set('key', 'value');\n\nawait kv.get('key'); // value\n```\n\n## Multiple namespaces\n\nUsing multiple namespaces so you dont get conflicts\n\n```javascript\nconst users = new KV(undefined, 'users');\nconst posts = new KV(undefined, 'posts');\n\nawait users.set('one', 'user');\nawait posts.set('one', 'post');\n\nawait users.get('one'); // user\nawait posts.get('one'); // post\n```\n\n## All values in namespace\n\nEasily get all values in a namespace\n\n```javascript\nconst users = new KV(undefined, 'users');\n\nawait users.set('one', 'user');\nawait users.set('two', 'user');\n\nawait users.all(); // [{key: 'users:one', value: 'user'}, {key: 'users:two', value: 'user'}]\n```\n\n## Delete a key\n\nDelete key in your current namespace\n\n```javascript\nconst users = new KV(undefined, 'users');\n\nawait users.del('one', 'user');\n\nawait users.get('one'); // undefined\n```\n\n## Clear a namespace\n\nClear a whole namespace\n\n```javascript\nconst users = new KV(undefined, 'users');\n\nawait users.set('one', 'user');\nawait users.clear();\n\nawait users.get('one'); // undefined\n```\n\n## Mongoose error events\n\n```javascript\nconst kv = new KV('mongodb://123/');\n\nkv.on('error', e =\u003e console.log(e));\n```\n\n## TTL\n\n```javascript\nconst kv = new KV(undefined, 'ttl');\n\nawait kv.set('test', 'hi', 5000); // 5 seconds\nsetTimeout(() =\u003e console.log(await kv.get('test')), 5000); // undefined\n```\n\n[MIT](https://github.com/QGIsK/kv/blob/main/LICENSE) Demian\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqgisk%2Fkv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqgisk%2Fkv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqgisk%2Fkv/lists"}