{"id":13540937,"url":"https://github.com/dat-ecosystem-archive/multidat","last_synced_at":"2025-04-02T08:30:52.925Z","repository":{"id":57305200,"uuid":"80667057","full_name":"dat-ecosystem-archive/multidat","owner":"dat-ecosystem-archive","description":"Manage multiple dat instances [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ] ","archived":true,"fork":false,"pushed_at":"2022-01-06T16:15:32.000Z","size":31,"stargazers_count":22,"open_issues_count":3,"forks_count":6,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-16T13:13:58.640Z","etag":null,"topics":["dat","manage","multiplex"],"latest_commit_sha":null,"homepage":"","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/dat-ecosystem-archive.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":"2017-02-01T21:39:23.000Z","updated_at":"2023-01-28T04:17:54.000Z","dependencies_parsed_at":"2022-09-15T14:52:38.136Z","dependency_job_id":null,"html_url":"https://github.com/dat-ecosystem-archive/multidat","commit_stats":null,"previous_names":["datproject/multidat"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fmultidat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fmultidat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fmultidat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fmultidat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dat-ecosystem-archive","download_url":"https://codeload.github.com/dat-ecosystem-archive/multidat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246781875,"owners_count":20832924,"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":["dat","manage","multiplex"],"created_at":"2024-08-01T10:00:36.353Z","updated_at":"2025-04-02T08:30:52.624Z","avatar_url":"https://github.com/dat-ecosystem-archive.png","language":"JavaScript","funding_links":[],"categories":["Using Dat"],"sub_categories":["Hosting \u0026 Dat Management"],"readme":"[![deprecated](http://badges.github.io/stability-badges/dist/deprecated.svg)](https://dat-ecosystem.org/) \n\nMore info on active projects and modules at [dat-ecosystem.org](https://dat-ecosystem.org/) \u003cimg src=\"https://i.imgur.com/qZWlO1y.jpg\" width=\"30\" height=\"30\" /\u003e \n\n---\n\n# multidat\n[![npm version][2]][3] [![build status][4]][5] [![test coverage][6]][7]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nManage multiple [dat][dat] instances in multiple locations.\n\n## Usage\n```js\nvar Multidat = require('multidat')\nvar toilet = require('toiletdb')\n\nvar db = toilet('/tmp/dat')\nMultidat(db, function (err, multidat) {\n  if (err) throw err\n\n  multidat.create(opts, function (err, dat) {\n    if (err) throw err\n\n    var dats = multidat.list()\n    console.log(dats)\n\n    multidat.close(dat.archive.key, function (err) {\n      if (err) throw err\n      console.log()\n    })\n  })\n})\n```\n\n## Error handling\nIf there is an error initializing a dat, instead of the whole process failing, an error object with attached `.dir` property will be pushed into the list of dats instead. That means when consuming `multidat.list()`, you should check for errors:\n\n```js\nvar dats = multidat.list()\ndats.forEach(function (dat) {\n  if (dat instanceof Error) {\n    var err = dat\n    console.log('failed to initialize dat in %s: %s', err.dir, err.message)\n  }\n})\n```\n\nThis way you can decide for yourself whether an individual initialization failure should cause the whole process to fail or not.\n\n## API\n### Multidat(db, opts, callback(err, multidat))\nCreat a new Multidat instance. Takes a `toiletdb` instance and a callback.\n\nOptions:\n\n- `Dat`: Use provided dat factory instead of [dat-node](https://github.com/datproject/dat-node)\n\n### multidat.create(dir, opts, callback(err, dat))\nCreate a new `dat` archive.\n\n### dats = multidat.list()\nList all available `dat` archives.\n\n### multidat.close(key, callback(err))\nClose and remove a `dat` archive.\n\n### multidat.readManifest(dat, callback(err, manifest))\nRead the `dat.json` file from the `dat` archive. This method is expected to be\ndeprecated once `dat` archives provide a built-in method to return archives.\n\n## Why?\nThis package exists to manage multiple `dat` archives in different directories.\nThe [dat-node][dat-node] package is mostly stateless; all state is persisted\ninto the archives themselves. This package acts as a layer on top to keep track\nof where archives are located and manage them between sessions.\n\n## When not to use this\nIf you're running a server, it's usually enough to run\n[mafintosh/hypercore-archiver](https://github.com/mafintosh/hypercore-archiver)\nwhich is more consistent and simpler. If you're building a tool that only needs\nto manage a single dat archive at the time it's recommended to use\n[datproject/dat-node][dat-node] instead.\n\n## See Also\n- [datproject/dat-node][dat-node]\n- [mafintosh/hyperdrive](https://github.com/mafintosh/hyperdrive)\n- [mafintosh/hypercore-archiver](https://github.com/mafintosh/hypercore-archiver)\n- [datproject/multidrive](https://github.com/datproject/multidrive)\n- [juliangruber/hyperdrive-stats](https://github.com/juliangruber/hyperdrive-stats)\n- [juliangruber/dat-encoding](https://github.com/juliangruber/dat-encoding)\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/multidat.svg?style=flat-square\n[3]: https://npmjs.org/package/multidat\n[4]: https://img.shields.io/travis/datproject/multidat/master.svg?style=flat-square\n[5]: https://travis-ci.org/datproject/multidat\n[6]: https://img.shields.io/codecov/c/github/datproject/multidat/master.svg?style=flat-square\n[7]: https://codecov.io/github/datproject/multidat\n[8]: http://img.shields.io/npm/dm/multidat.svg?style=flat-square\n[9]: https://npmjs.org/package/multidat\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n[dat]: https://github.com/datproject/dat\n[dat-node]: https://github.com/datproject/dat-node\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdat-ecosystem-archive%2Fmultidat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdat-ecosystem-archive%2Fmultidat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdat-ecosystem-archive%2Fmultidat/lists"}