{"id":19542293,"url":"https://github.com/ruffrey/kval","last_synced_at":"2025-06-22T10:36:13.468Z","repository":{"id":36027358,"uuid":"40323290","full_name":"ruffrey/kval","owner":"ruffrey","description":"simple, experimental key-value store atop LMDB","archived":false,"fork":false,"pushed_at":"2015-08-06T19:35:33.000Z","size":464,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T05:26:46.065Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ruffrey.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}},"created_at":"2015-08-06T19:34:08.000Z","updated_at":"2015-08-06T19:34:35.000Z","dependencies_parsed_at":"2022-09-08T09:11:06.632Z","dependency_job_id":null,"html_url":"https://github.com/ruffrey/kval","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ruffrey/kval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Fkval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Fkval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Fkval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Fkval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruffrey","download_url":"https://codeload.github.com/ruffrey/kval/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Fkval/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261279913,"owners_count":23134895,"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-11T03:14:03.699Z","updated_at":"2025-06-22T10:36:08.434Z","avatar_url":"https://github.com/ruffrey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kval - under construction / unfinished\n\nA simplistic and easy to scale JSON document datastore. (experimental)\n\n- wickedly fast\n    - see [LMDB benchmarks](http://symas.com/mdb/#bench) upon which it is built\n- ACID compliant - supports transactions\n- persistent\n- store size can be larger than memory\n- JSON store supporting very large documents\n- a single instance scales to over 1 billion records\n- Peering (coming soon)\n    - peer pub-sub\n    - eventual consistency\n    - adds redundancy and horizontal traffic capacity\n\n## Goals\n\n- one-line install and fast setup with no prior knowledge\n- add redundancy in minutes\n- minimal APIs to learn\n- APIs that are familiar to NoSQL developers\n- should be usable for minimum viable products that don't want to worry about scaling for a while\n- small, well tested, maintainable codebase with few dependencies\n\nkval uses a simplified Node.js Mongoose-like API.\n\n## Quickstart\n\nkval is a Node.js app with bindings to LMDB, so it can be run in a lot of ways,\nincluding `require`d into a Node.js project (see instructions below for *Embedding*).\n\nBelow are instructions for running it as an independent service.\n\n### Install on Ubuntu\n\n(link tbd)\n\n```bash\ncurl https://storage.googleapis.com/kval/ubuntu.sh -o kval-install.sh\nsh kval-install.sh\n```\n\n### Running on OSX\n\nThere is no installation script. For now you can run it as a Node.js app.\n\n```bash\ngit clone \u003cTODO: INSERT REPOSITORY\u003e\ncd kval \u0026\u0026 npm i --production\nnode worker.js\n```\n\n## Advanced setup\n\nAt it's core this is a Node.js app, so running it is up to you. There are a\nvariety of way to run Node.js apps.\n\nkval uses environment variables for its configuration.\n\n```bash\nKVAL_WORKER_HOST=0.0.0.0\nKVAL_WORKER_PORT=9226\nKVAL_WORKER_DB_PATH=/path/to/db/files\nKVAL_WORKER_DB_MAX_SIZE_BYTES=524288000 # 500 MiB\nKVAL_WORKER_PASSWORD=\"secret-stuff\"\n```\n\n## Node.js client usage\n\n### Connecting\n\n```javascript\nvar Kval = require('kval').Client;\nvar kval = new Kval();\n\nkval.connect({\n    host: '127.0.0.1',\n    port: 9226,\n    password: 'swordfish'\n}, function (err) {\n    if (err) {\n        console.error(err.message);\n        return;\n    }\n    console.log('Connected!');\n});\n```\n\n### Creating and updating\n\n```javascript\nvar schema = {\n    properties: {\n        name: {\n            type: 'string'\n            index: true // makes it searchable, non-indexed fields are not\n        },\n        age: {\n            type: 'number'\n        },\n        libraryCard: {\n            type: 'string',\n            unique: true // makes it searchable and ensures uniqueness\n        }\n    }\n};\n\nvar User = client.model('User4', schema);\nvar user = new User({ name: 'Bill', age: 32, libraryCard: 'A-55555' });\n\nconsole.log(user.id); // auto generated id field\n\nuser.save(function callback(err, savedUser) {\n    if (err) {\n        console.error(err.message);\n        return;\n    }\n    console.log('User was saved', savedUser);\n    savedUser.age++;\n    savedUser.save(function (err) {\n        console.log('User got old');\n    });\n});\n```\n\n### Finding\n\n```javascript\nUser.findById(id, callback);\nUser.find({ someIndex: 'someValue' }, callback);\n```\n\n### Deleting\n\n```javascript\nUser.findById('Yrei32kLisd9gaknbl9akNyr', function (err, user) {\n    if (err) { console.error(err); }\n    user.remove(function (err) {\n        if (err) { console.error(err); }\n        console.log('User was removed successfully.');\n    })\n});\n```\n\n## Other languages\n\nDrivers for other languages have not been added yet. Please open an issue\nif you are interested in support for a language other than Node, or if you\ncreated one and would like us to list it here.\n\n## Architecture and protocol\n\nkval is a thin layer over the LMDB keystore:\n\n- a simple database management system (dbms) for storing JSON\ndocuments\n- a pre-shared password auth scheme\n    - two step handshake to establish a secure session\n    - subsequent requests are fully encrypted\n- RPC protocol over TCP\n    - uses [dnode, which supports many languages](https://github.com/substack/dnode#dnode-in-other-languages)\n\n### Embedding\n\nkval can be embedded in a Node.js application.\n\n```javascript\nvar Dbms = require('kval').Dbms;\nvar db = new Dbms();\nvar options = {\n    host: '0.0.0.0',\n    port: 9226,\n    path: 'path/to/db',\n    mapSize: 1024 * 1024 * 1024 * 50, // Max db size in bytes\n    password: 'not-a-secret'\n};\ndb.initialize(options, function callback(err) {\n\n});\n```\n\nReal examples of embedding can be seen in most of the tests - see the `test/` folder.\n\n## keys / ID / `.id` field\n\n`id`s must be unique, as this is a key-value store at its heart, with JSON\ndocuments as the values.\n\nThe key can be any JSON type.\n\nBy default the Node.js client library will assign keys when they are not\nspecified. The default `ids` are\n**24 character pseudo-random case-sensitive alphanumeric strings** which should guarantee uniqueness.\n\n## Backups\n\nBackup the `data.mdb` and `lock.mdb` files in your `KVAL_WORKER_DB_PATH`.\n\nTo restore, put the two files back into the `KVAL_WORKER_DB_PATH`.\n\n## Benchmarks\n\nBenchmarks for basic CRUD and other scenarios are in the `test/benchmarks/` folder. Having multiple instances of `worker.js` would improve benchmarks (i.e. using Node.js cluster).\n\n\nRun benchmarks with\n```bash\nnpm run bench\n```\n\n## Tests\n\n```bash\nnpm test\n```\n\nTest coverage can be seen by running\n```bash\nnpm run cover\n```\n\nThe coverage goal is at least 90%, currently at about 70%.\n\n\n## Work list to v1.0.0\n\n- peering with pub-sub\n- client multi-connection pooling\n- finish queries\n- test 1 billion records\n- increment ability on integer fields\n- schema validation\n- bulk create, update, and delete\n- list dbis (collections)\n\n# Licensing\n\n### kval\n\nMIT\n\nSee LICENSE file in the repository\n\n### LMDB\nOpenLDAP Public License\n\n### Other dependencies\nSee deps in `package.json` to track licenses\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruffrey%2Fkval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruffrey%2Fkval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruffrey%2Fkval/lists"}