{"id":15152888,"url":"https://github.com/ipfs/interface-datastore","last_synced_at":"2025-09-30T01:31:18.489Z","repository":{"id":17934386,"uuid":"20908964","full_name":"ipfs/interface-datastore","owner":"ipfs","description":"datastore interface","archived":true,"fork":false,"pushed_at":"2021-09-09T11:19:13.000Z","size":1670,"stargazers_count":23,"open_issues_count":8,"forks_count":20,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-05-06T04:03:01.199Z","etag":null,"topics":[],"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/ipfs.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}},"created_at":"2014-06-17T03:27:46.000Z","updated_at":"2023-10-13T21:05:31.000Z","dependencies_parsed_at":"2022-07-10T06:47:08.697Z","dependency_job_id":null,"html_url":"https://github.com/ipfs/interface-datastore","commit_stats":null,"previous_names":["jbenet/node-datastore"],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Finterface-datastore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Finterface-datastore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Finterface-datastore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs%2Finterface-datastore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipfs","download_url":"https://codeload.github.com/ipfs/interface-datastore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":201328964,"owners_count":13851214,"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-09-26T16:41:04.282Z","updated_at":"2025-09-30T01:31:18.093Z","avatar_url":"https://github.com/ipfs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⛔️ DEPRECATED: This module has been merged into by the [ipfs-interfaces](https://github.com/ipfs/js-ipfs-interfaces) module \u003c!-- omit in toc --\u003e\n\n# interface-datastore \u003c!-- omit in toc --\u003e\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)\n[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)\n[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)\n[![codecov](https://img.shields.io/codecov/c/github/ipfs/interface-datastore.svg?style=flat-square)](https://codecov.io/gh/ipfs/interface-datastore)\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ipfs/interface-datastore/ci?label=ci\u0026style=flat-square)](https://github.com/ipfs/interface-datastore/actions?query=branch%3Amaster+workflow%3Aci+)\n\n\u003e Implementation of the [datastore](https://github.com/ipfs/go-datastore) interface in JavaScript\n\n## Lead Maintainer \u003c!-- omit in toc --\u003e\n\n[Alex Potsides](https://github.com/achingbrain)\n\n## Table of Contents \u003c!-- omit in toc --\u003e\n\n- [Implementations](#implementations)\n- [Adapter](#adapter)\n- [Install](#install)\n- [Usage](#usage)\n  - [Wrapping Stores](#wrapping-stores)\n  - [Test suite](#test-suite)\n  - [Aborting requests](#aborting-requests)\n  - [Concurrency](#concurrency)\n  - [Keys](#keys)\n- [API](#api)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Implementations\n\n- Backed Implementations\n  - Memory: [`src/memory`](src/memory.js)\n  - level: [`datastore-level`](https://github.com/ipfs/js-datastore-level) (supports any levelup compatible backend)\n  - File System: [`datstore-fs`](https://github.com/ipfs/js-datastore-fs)\n- Wrapper Implementations\n  - Mount: [`datastore-core/src/mount`](https://github.com/ipfs/js-datastore-core/tree/master/src/mount.js)\n  - Keytransform: [`datstore-core/src/keytransform`](https://github.com/ipfs/js-datastore-core/tree/master/src/keytransform.js)\n  - Sharding: [`datastore-core/src/sharding`](https://github.com/ipfs/js-datastore-core/tree/master/src/sharding.js)\n  - Tiered: [`datstore-core/src/tiered`](https://github.com/ipfs/js-datastore-core/blob/master/src/tiered.js)\n  - Namespace: [`datastore-core/src/namespace`](https://github.com/ipfs/js-datastore-core/tree/master/src/namespace.js)\n\nIf you want the same functionality as [go-ds-flatfs](https://github.com/ipfs/go-ds-flatfs), use sharding with fs.\n\n```js\nconst FsStore = require('datastore-fs')\nconst ShardingStore = require('datastore-core').ShardingDatastore\nconst NextToLast = require('datastore-core').shard.NextToLast\n\nconst fs = new FsStore('path/to/store')\n\n// flatfs now works like go-flatfs\nconst flatfs = await ShardingStore.createOrOpen(fs, new NextToLast(2))\n```\n\n## Adapter\n\nAn adapter is made available to make implementing your own datastore easier:\n\n```javascript\nconst { Adapter } = require('interface-datastore')\n\nclass MyDatastore extends Adapter {\n  constructor () {\n    super()\n  }\n\n  async put (key, val) {\n    // your implementation here\n  }\n\n  async get (key) {\n    // your implementation here\n  }\n\n  // etc...\n}\n```\n\nSee the [MemoryDatastore](./src/memory.js) for an example of how it is used.\n\n## Install\n\n```sh\n$ npm install interface-datastore\n```\n\n## Usage\n\n### Wrapping Stores\n\n```js\nconst MemoryStore = require('interface-datastore').MemoryDatastore\nconst MountStore = require('datastore-core').MountDatastore\nconst Key = require('interface-datastore').Key\n\nconst store = new MountStore({ prefix: new Key('/a'), datastore: new MemoryStore() })\n```\n\n### Test suite\n\nAvailable under [`src/tests.js`](src/tests.js)\n\n```js\ndescribe('mystore', () =\u003e {\n  require('interface-datastore/src/tests')({\n    async setup () {\n      return instanceOfMyStore\n    },\n    async teardown () {\n      // cleanup resources\n    }\n  })\n})\n```\n\n### Aborting requests\n\nMost API methods accept an [AbortSignal][] as part of an options object.  Implementations may listen for an `abort` event emitted by this object, or test the `signal.aborted` property. When received implementations should tear down any long-lived requests or resources created.\n\n### Concurrency\n\nThe streaming `(put|get|delete)Many` methods are intended to be used with modules such as [it-parallel-batch](https://www.npmjs.com/package/it-parallel-batch) to allow calling code to control levels of parallelisation.  The batching method ensures results are returned in the correct order, but interface implementations should be thread safe.\n\n```js\nconst batch = require('it-parallel-batch')\nconst source = [{\n  key: ..,\n  value: ..\n}]\n\n// put values into the datastore concurrently, max 10 at a time\nfor await (const { key, data } of batch(store.putMany(source), 10)) {\n  console.info(`Put ${key}`)\n}\n```\n\n### Keys\n\nTo allow a better abstraction on how to address values, there is a `Key` class which is used as identifier. It's easy to create a key from a `Uint8Array` or a `string`.\n\n```js\nconst a = new Key('a')\nconst b = new Key(new Uint8Array([0, 1, 2, 3]))\n```\n\nThe key scheme is inspired by file systems and Google App Engine key model. Keys are meant to be unique across a system. They are typically hierarchical, incorporating more and more specific namespaces. Thus keys can be deemed 'children' or 'ancestors' of other keys:\n\n- `new Key('/Comedy')`\n- `new Key('/Comedy/MontyPython')`\n\nAlso, every namespace can be parameterized to embed relevant object information. For example, the Key `name` (most specific namespace) could include the object type:\n\n- `new Key('/Comedy/MontyPython/Actor:JohnCleese')`\n- `new Key('/Comedy/MontyPython/Sketch:CheeseShop')`\n- `new Key('/Comedy/MontyPython/Sketch:CheeseShop/Character:Mousebender')`\n\n## API\nhttps://ipfs.github.io/interface-datastore/\n\n## Contribute\n\nPRs accepted.\n\nSmall note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## License\n\nMIT 2017 © IPFS\n\n\n[Key]: #Keys\n[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\n[Uint8Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array\n[AbortSignal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\n[AsyncIterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator\n[AsyncIterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols\n[String]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\n[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\n[Function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\n[Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\n[Boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs%2Finterface-datastore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipfs%2Finterface-datastore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs%2Finterface-datastore/lists"}