{"_id":"datastore.abstract","_rev":"4642876","name":"datastore.abstract","description":"datastore","dist-tags":{"latest":"0.0.1"},"maintainers":[{"name":"jbenet","email":""}],"time":{"modified":"2026-04-10T20:05:33.000Z","created":"2014-06-17T03:34:09.820Z","0.0.1":"2014-06-17T04:04:55.786Z","0.0.0":"2014-06-17T03:34:09.820Z"},"users":{},"author":{"name":"Juan Benet","email":"juan@benet.ai","url":"http://juan.benet.ai/"},"repository":{"type":"git","url":"https://github.com/jbenet/node-datastore.git"},"versions":{"0.0.1":{"name":"datastore.abstract","version":"0.0.1","description":"datastore","main":"index.js","scripts":{"test":"node test.js"},"keywords":["datastore","abstract"],"author":{"name":"Juan Benet","email":"juan@benet.ai","url":"http://juan.benet.ai/"},"license":"MIT","devDependencies":{"tape":"^2.13.3"},"dependencies":{"inherits":"^2.0.1","xtend":"^3.0.0"},"repository":{"type":"git","url":"https://github.com/jbenet/node-datastore.git"},"bugs":{"url":"https://github.com/jbenet/node-datastore/issues"},"homepage":"https://github.com/jbenet/node-datastore","gitHead":"f9350ce64a242594f28f5efb5b01617238f7f4fa","_id":"datastore.abstract@0.0.1","_shasum":"7ef771bfdd7ba7960c3851c150b1145d07687286","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"jbenet","email":"juan@benet.ai"},"maintainers":[{"name":"jbenet","email":""}],"dist":{"shasum":"7ef771bfdd7ba7960c3851c150b1145d07687286","size":2225,"noattachment":false,"key":"/datastore.abstract/-/datastore.abstract-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/datastore.abstract/download/datastore.abstract-0.0.1.tgz"},"directories":{},"publish_time":1402977895786,"_hasShrinkwrap":false,"_cnpm_publish_time":1402977895786,"_cnpmcore_publish_time":"2021-12-16T20:51:51.910Z"},"0.0.0":{"name":"datastore.abstract","version":"0.0.0","description":"datastore","main":"index.js","scripts":{"test":"node test.js"},"keywords":["datastore","abstract"],"author":{"name":"Juan Benet","email":"juan@benet.ai","url":"http://juan.benet.ai/"},"license":"MIT","devDependencies":{"tape":"^2.13.3"},"dependencies":{"inherits":"^2.0.1","xtend":"^3.0.0"},"repository":{"type":"git","url":"https://github.com/jbenet/datastore.abstract.git"},"bugs":{"url":"https://github.com/jbenet/datastore.abstract/issues"},"homepage":"https://github.com/jbenet/datastore.abstract","gitHead":"f58a9b26d9585a948cccaf08219d0cb1bcd73861","_id":"datastore.abstract@0.0.0","_shasum":"24df0e243de20180d0bb91a23be8c63474dee88a","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"jbenet","email":"juan@benet.ai"},"maintainers":[{"name":"jbenet","email":""}],"dist":{"shasum":"24df0e243de20180d0bb91a23be8c63474dee88a","size":2220,"noattachment":false,"key":"/datastore.abstract/-/datastore.abstract-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/datastore.abstract/download/datastore.abstract-0.0.0.tgz"},"directories":{},"publish_time":1402976049820,"_hasShrinkwrap":false,"_cnpm_publish_time":1402976049820,"_cnpmcore_publish_time":"2021-12-16T20:51:52.212Z"}},"readme":"# node-datastore interface\n\ndatastore is a generic layer of abstraction for data store and database access. It is a simple API with the aim to enable application development in a datastore-agnostic way, allowing datastores to be swapped seamlessly without changing application code. Thus, one can leverage different datastores with different strengths without committing the application to one datastore throughout its lifetime.\n\nIn addition, grouped datastores significantly simplify interesting data access patterns (such as caching and sharding).\n\nBased on [datastore.py](https://github.com/jbenet/datastore).\n\nNote: this is similar to [rvagg/abstract-leveldown](https://github.com/rvagg/abstract-leveldown/). Though I wrote [my original datastore](https://github.com/jbenet/datastore) many years ago. :)\n\n## Example\n\n### Usage\n\nSee [datastore.memory/try.js](https://github.com/jbenet/node-datastore.memory/blob/master/try.js):\n\n```js\nvar memDS = require('datastore.memory')\nds.put('foo', 'bar', function(err, val, key) {\n  if (err) throw err\n  console.log('put ' + key + ': ' + val)\n  assert(val === 'bar')\n})\n\nds.has('foo', function(err, has, key) {\n  if (err) throw err\n  console.log(key + ' exists? ' + has)\n  assert(has === true)\n})\n\nds.get('foo', function(err, val, key) {\n  if (err) throw err\n  console.log('get ' + key + ': ' + val)\n  assert(val === 'bar')\n})\n\nds.delete('foo', function(err, key) {\n  if (err) throw err\n  console.log(key + ' deleted')\n})\n\nds.has('foo', function(err, has, key) {\n  if (err) throw err\n  console.log(key + ' exists? ' + has)\n  assert(has === false)\n})\n```\n\n### Implementation\n\nSee [datastore.memory/index.js](https://github.com/jbenet/node-datastore.memory/blob/master/index.js):\n\n```js\nvar DS = require('datastore.abstract')\n\nmodule.exports = MemDS\n\nfunction MemDS() {\n  if (!(this instanceof MemDS))\n    return new MemDS\n  DS.call(this)\n  this.values = {}\n}\n\nDS.inherits(MemDS)\n\nMemDS.prototype._get = function(key, cb) {\n  var val = this.values[key.toString()]\n  if (val !== undefined) cb(null, val, key)\n  else cb(MemDS.errors.NotFound, null, key)\n}\n\nMemDS.prototype._put = function(key, val, cb) {\n  this.values[key.toString()] = val\n  cb(null, val, key)\n}\n\nMemDS.prototype._delete = function(key, cb) {\n  delete this.values[key.toString()]\n  cb(null, key)\n}\n\nMemDS.prototype._has = function(key, cb) {\n  var has = (this.values[key.toString()] !== undefined)\n  cb(null, has, key)\n}\n```\n\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/jbenet/node-datastore","bugs":{"url":"https://github.com/jbenet/node-datastore/issues"},"license":"MIT"}