{"id":17315345,"url":"https://github.com/frando/multihyperdb","last_synced_at":"2026-04-06T04:32:14.793Z","repository":{"id":57305233,"uuid":"126986745","full_name":"Frando/multihyperdb","owner":"Frando","description":"Manage many hyperdbs.","archived":false,"fork":false,"pushed_at":"2018-03-27T14:26:11.000Z","size":29,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T03:41:27.174Z","etag":null,"topics":["hyperdb"],"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/Frando.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":"2018-03-27T12:59:30.000Z","updated_at":"2023-06-04T06:23:08.000Z","dependencies_parsed_at":"2022-09-19T08:30:19.780Z","dependency_job_id":null,"html_url":"https://github.com/Frando/multihyperdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frando%2Fmultihyperdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frando%2Fmultihyperdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frando%2Fmultihyperdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frando%2Fmultihyperdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Frando","download_url":"https://codeload.github.com/Frando/multihyperdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248900303,"owners_count":21180172,"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":["hyperdb"],"created_at":"2024-10-15T13:07:43.489Z","updated_at":"2026-04-06T04:32:14.749Z","avatar_url":"https://github.com/Frando.png","language":"JavaScript","readme":"# MultiHyperDB\n\nManage many [hyperdbs](https://github.com/mafintosh/hyperdb)s\n\n## Installation\n\n`npm install multihyperdb`\n\n## Usage\n\n```js\n\nvar multi = require('multihyperdb')\n\nvar opts = {\n  path: './db',\n  dbOpts: {valueEncoding: 'json'}\n}\n\nvar Multi = multi(opts)\n\nmulti.createDB({}, {name: 'First database'}, function(err, db) {\n  db.put('hello', 'world', function (err, node) { } )\n})\n\n```\n\n## API\n\n#### `var multi = multihyperdb(opts)`\n\nCreate a new MultiHyperDB. Stores info about multiple hyperdbs in a master hyperdb.\n\nOptions include:\n\n```js\n{\n  path: './db' // Path to store the databases in\n  masterPath, dbPath // Set basepath for master databases and child databases manually\n  dbOpts // default hyperdb opts for child databases\n  storage // callback to return a random-access-storage (see below)\n}\n```\n\n#### `multi.createDB(opts, meta, cb)`\n\nCreate a new hyperdb. `opts` are regular hyperdb opts (they override the global `dbOpts`). `meta` may have any JSON to be stored in the master hyperdb for this child db. `cb` will be called with `(err, db)` after the database is ready.\n\n#### `multi.addDB(key, opts, meta, cb)`\n\nAdd a hyperdb with key `key`. Other options as in `createDB`.\n\n#### `multi.dropDB(key, opts, cb)`\n\nDrop database `key` from being managed in this MultiHyperDB. Pass `{delete: true}` as opts to physically delete the database from disc.\n\n#### `multi.each(callback)`\n\nExecute a callback for each database. `callback`s parameters are `(db, key, meta)`.\n\n#### `multi.createReadStream(prefix)`\n\nGet a combined read stream on all child databases. The `on('data'` callback receives an object with properties `node` (the node as returned from a regular hyperdb read stream, with `key` and `value` properties) and `dbKey` (the key of the database).\n\n#### `multi.getDB(key)`\n\nGet a database by key.\n\n#### `multi.getDBbyProperty(prop, value, [single])`\n\nGet a database by meta property. If `single` is true, only the first matching database is returned.\n\n### Custom storage \n\nBy default, both master and child dbs are created with random-access-file storage in the path(s) configured via opts. Alternatively, pass a function as `opts.storage`.\n\n```js\nopts.storage = function(master, key, destroy, cb) {\n}\n```\nIf `destroy` is false, return a random-access-storage for either master (if `master` is `true`) or the child database with key `key`. If destroy is `true`, destroy (delete) the child database with key `key` and call the callback `cb`.\n\n### Syncing and sharing\n\n... is as simple as\n\n```js\n\nvar multi = require('multihyperdb')\nvar hyperdiscovery = require('hyperdiscovery')\n\nvar Multi = multi({path: './db1'})\n\n// Create some databases or add existing keys.\n\n// Two-way sync them all!\nMulti.each(function(db) {\n  hyperdiscovery(db, {live: true})\n})\n```\n\nTry it out with example-cli.js:\n\n```\n$ node example-cli.js db1 create myfirstdb\ndb created with key: d7f69b22386fdc7751fb26e6a458a45c1a5d369525ac0e428eaf0331f59ff0e1\n\n$ node example-cli.js db1 write myfirstdb hello world\nWrote node: Node(key=hello, value='world', seq=0, feed=0))\n\n$ node example-cli.js db1 share\n\n\n# In another terminal or on another computer\n\n$ node example-cli.js db2 add remotedb d7f69b22386fdc7751fb26e6a458a45c1a5d369525ac0e428eaf0331f59ff0e1 \n$ node example-cli.js db2 share\n\n# wait, then abort\n\n$ node example-cli.js db2 read\nNode(key=hello, value='world', seq=0, feed=0))\n\n# This was synced from db1.myfirstdb !\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrando%2Fmultihyperdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrando%2Fmultihyperdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrando%2Fmultihyperdb/lists"}