{"name":"level-sublevel","description":"partition levelup databases","version":"6.2.2","homepage":"https://github.com/dominictarr/level-sublevel","repository":{"type":"git","url":"git://github.com/dominictarr/level-sublevel.git"},"dependencies":{"pull-stream":"~2.21.0","ltgt":"~1.0.2","levelup":"https://codeload.github.com/dominictarr/node-levelup/tar.gz/inject"},"devDependencies":{"bytewise":"~0.7.0","level":"~0.18.0","level-test":">=1.5.1 <2","monotonic-timestamp":"0.0.8","pull-level":"~1.1.1","rimraf":"~2.1.4","shasum":"0.0.2","stream-to-pull-stream":"~1.2.0","tape":"~2.13.3","through":"~2.3.4","leveldown":"~0.10.2"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","stability":"unstable","testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/17..latest","firefox/nightly","chrome/22..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/dominictarr/level-sublevel/issues"},"_id":"level-sublevel@6.2.2","_shasum":"2920a34fedf666391caa15b9f2e6f739a7bdf349","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"dist":{"shasum":"2920a34fedf666391caa15b9f2e6f739a7bdf349","tarball":"http://registry-npm.ywwl.com/level-sublevel/download/level-sublevel-6.2.2.tgz","integrity":"sha512-DfHLHeHpVNw4/aNeX1KGJlt/G8hUim1sGV/VhJ/wgiAuOCy1It5GLG7cV4vjrUjKFIlJhomsohoVNW7GVRRDTg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCe50cdItLoiCnoHVc0zLy++kXwAtvlqWJOwgBWTLJcIgIhAOeqFwOX1FX31nMCYjwg0F3mJG5Fy0shEO0EOzXgV4fh"}],"size":18006,"noattachment":false,"key":"/level-sublevel/-/level-sublevel-6.2.2.tgz"},"directories":{},"readme":"# level-sublevel\n\nSeparate sections of levelup, with hooks!\n\n[![build status](https://secure.travis-ci.org/dominictarr/level-sublevel.png)](http://travis-ci.org/dominictarr/level-sublevel)\n\n[![testling badge](https://ci.testling.com/dominictarr/level-sublevel.png)](https://ci.testling.com/dominictarr/level-sublevel)\n\nThis module allows you to create seperate sections of a\n[levelup](https://github.com/rvagg/node-levelup) database,\nkinda like tables in an sql database, but evented, and ranged,\nfor real-time changing data.\n\n## level-sublevel@6 **BREAKING CHANGES**\n\nThe long awaited `level-sublevel` rewrite is out!\nYou are hearby warned this is a _significant breaking_ change.\nSo it's good to use it with a new project,\nThe user api is _mostly_ the same as before,\nbut the way that keys are _encoded_ has changed, and _this means\nyou cannot run 6 on a database you created with 5_.\n\nAlso, `createWriteStream` has been removed, in anticipation of [this\nchange](https://github.com/rvagg/node-levelup/pull/207) use something\nlike [level-write-stream](https://github.com/Raynos/level-write-stream)\n\n### Legacy Mode\n\nUsing leveldb with legacy mode is the simplest way to get the new sublevel\non top of a database that used old sublevel. Simply require sublevel like this:\n\n``` js\nvar level = require('level')\n                                   //  V *** require legacy.js ***\nvar sublevel = require('level-sublevel/legacy')\nvar db = sublevel(level(path))\n\n```\n\n### Migration Tool\n\n@calvinmetcalf has created a migration tool:\n[sublevel-migrate](https://github.com/calvinmetcalf/sublevel-migrate)\n\nThis can be used to copy an old level-sublevel into the new format.\n\n## Stability\n\nUnstable: Expect patches and features, possible api changes.\n\nThis module is working well, but may change in the future as its use is further explored.\n\n## Example\n\n``` js\nvar LevelUp = require('levelup')\nvar Sublevel = require('level-sublevel')\n\nvar db = Sublevel(LevelUp('/tmp/sublevel-example'))\nvar sub = db.sublevel('stuff')\n\n//put a key into the main levelup\ndb.put(key, value, function () {})\n\n//put a key into the sub-section!\nsub.put(key2, value, function () {})\n```\n\nSublevel prefixes each subsection so that it will not collide\nwith the outer db when saving or reading!\n\n## Hooks\n\nHooks are specially built into Sublevel so that you can \ndo all sorts of clever stuff, like generating views or\nlogs when records are inserted!\n\nRecords added via hooks will be atomically inserted with the triggering change.\n\n### Hooks Example\n\nWhenever a record is inserted,\nsave an index to it by the time it was inserted.\n\n``` js\nvar sub = db.sublevel('SEQ')\n\ndb.pre(function (ch, add) {\n  add({\n    key: ''+Date.now(), \n    value: ch.key, \n    type: 'put',\n    // NOTE: pass the destination db to add the value to that subsection!\n    prefix: sub\n  })\n})\n\ndb.put('key', 'VALUE', function (err) {\n  // read all the records inserted by the hook!\n  sub.createReadStream().on('data', console.log)\n})\n```\n\nNotice that the `prefix` property to `add()` is set to `sub`, which tells the hook to save the new record in the `sub` section.\n\n## Batches\n\nIn `sublevel` batches also support a `prefix: subdb` property,\nif set, this row will be inserted into that database section,\ninstead of the current section, similar to the `pre` hook above.\n\n``` js\nvar sub1 = db.sublevel('SUB_1')\nvar sub2 = db.sublevel('SUM_2')\n\nsub.batch([\n  {key: 'key', value: 'Value', type: 'put'},\n  {key: 'key', value: 'Value', type: 'put', prefix: sub2},\n], function (err) {...})\n```\n\n## License\n\nMIT\n\n","publish_time":1407161843115,"_cnpm_publish_time":1407161843115,"dist-tags":{"dev":"6.1.6","latest":"6.6.5"}}