{"_id":"underscore.db","_rev":"28205","name":"underscore.db","description":"Use JavaScript objects as databases","dist-tags":{"latest":"0.7.0"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"time":{"modified":"2021-06-03T10:04:08.000Z","created":"2014-01-13T14:54:07.228Z","0.7.0":"2014-09-03T00:45:48.226Z","0.6.1":"2014-07-17T14:20:48.380Z","0.6.0":"2014-02-18T01:08:56.729Z","0.5.1":"2014-02-06T10:37:42.412Z","0.5.0":"2014-02-04T10:00:51.876Z","0.4.0":"2014-01-29T03:25:09.841Z","0.3.0":"2014-01-27T06:44:58.281Z","0.2.1":"2014-01-25T05:54:05.581Z","0.2.0":"2014-01-25T04:45:24.573Z","0.1.0":"2014-01-13T14:54:07.228Z"},"users":{},"author":{"name":"Typicode","email":"typicode@gmail.com"},"repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"versions":{"0.7.0":{"name":"underscore.db","version":"0.7.0","description":"Use JavaScript objects as databases","main":"src/node.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object","embed","embeddable"],"devDependencies":{"grunt":"~0.4.2","grunt-browserify":"~1.3.0","grunt-cli":"~0.1.11","grunt-contrib-jshint":"~0.7.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-watch":"~0.5.3","grunt-mocha-test":"~0.7.0","lodash":"^2.4.1","sinon":"~1.8.1","underscore":"^1.7.0"},"gitHead":"9da1bacff6fbd224615e0f52701e4de6af75efa6","bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.7.0","_shasum":"343f931799a426a7b74c88e3417a5e593719fb2f","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"dist":{"shasum":"343f931799a426a7b74c88e3417a5e593719fb2f","size":5095,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.7.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.7.0.tgz"},"directories":{},"publish_time":1409705148226,"_cnpm_publish_time":1409705148226,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.6.1":{"name":"underscore.db","version":"0.6.1","description":"Use JavaScript objects as databases","main":"src/node.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object","embed","embeddable"],"devDependencies":{"grunt":"~0.4.2","grunt-browserify":"~1.3.0","grunt-cli":"~0.1.11","grunt-contrib-jshint":"~0.7.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-watch":"~0.5.3","grunt-mocha-test":"~0.7.0","lodash":"^2.4.1","sinon":"~1.8.1","underscore":"^1.6.0"},"gitHead":"6cf0904fe1264ac1ac6e9072881258ebe99280d8","bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.6.1","_shasum":"9501310b800ed003d9fe1cc8a0bc4567a10c7469","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"dist":{"shasum":"9501310b800ed003d9fe1cc8a0bc4567a10c7469","size":5197,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.6.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.6.1.tgz"},"directories":{},"publish_time":1405606848380,"_cnpm_publish_time":1405606848380,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.6.0":{"name":"underscore.db","version":"0.6.0","description":"Use JavaScript objects as databases","main":"src/node.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object","embed","embeddable"],"devDependencies":{"underscore":"~1.5.2","lodash":"~2.4.1","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-cli":"~0.1.11","grunt-browserify":"~1.3.0","sinon":"~1.8.1"},"bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.6.0","dist":{"shasum":"f1469913e9f4d9fd459a786c5316daa993fd5a32","size":4905,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.6.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.6.0.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1392685736729,"_cnpm_publish_time":1392685736729,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.5.1":{"name":"underscore.db","version":"0.5.1","description":"Use JavaScript objects as databases","main":"src/node.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object"],"devDependencies":{"underscore":"~1.5.2","lodash":"~2.4.1","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-cli":"~0.1.11","grunt-browserify":"~1.3.0"},"bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.5.1","dist":{"shasum":"8ba41a692158d451ae2e5c3be6a0ea42fc521dcf","size":5657,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.5.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.5.1.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1391683062412,"_cnpm_publish_time":1391683062412,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.5.0":{"name":"underscore.db","version":"0.5.0","description":"Use JavaScript objects as databases","main":"src/node.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object"],"devDependencies":{"underscore":"~1.5.2","lodash":"~2.4.1","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-cli":"~0.1.11","grunt-browserify":"~1.3.0"},"_id":"underscore.db@0.5.0","dist":{"shasum":"11530de13bcb0bf076c11e61f8c26901acc5df48","size":5654,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.5.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.5.0.tgz"},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1391508051876,"_cnpm_publish_time":1391508051876,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.4.0":{"name":"underscore.db","version":"0.4.0","description":"Use JavaScript objects as databases","main":"dist/underscore.db.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object"],"devDependencies":{"underscore":"~1.5.2","lodash":"~2.4.1","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-contrib-copy":"~0.5.0","grunt-cli":"~0.1.11"},"bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.4.0","dist":{"shasum":"d9573f3558f841849312394c7a22f55a1a06d0e9","size":5046,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.4.0.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1390965909841,"_cnpm_publish_time":1390965909841,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.3.0":{"name":"underscore.db","version":"0.3.0","description":"Use JavaScript objects as databases","main":"dist/underscore.db.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object"],"devDependencies":{"underscore":"~1.5.2","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-contrib-copy":"~0.5.0","grunt-cli":"~0.1.11"},"_id":"underscore.db@0.3.0","dist":{"shasum":"e279d64693f51f3d15951f1b7eca908ddf9d641e","size":5502,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.3.0.tgz"},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1390805098281,"_cnpm_publish_time":1390805098281,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.2.1":{"name":"underscore.db","version":"0.2.1","description":"Use JavaScript objects as databases","main":"dist/underscore.db.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object"],"devDependencies":{"underscore":"~1.5.2","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-contrib-copy":"~0.5.0","grunt-cli":"~0.1.11"},"bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.2.1","dist":{"shasum":"dbf0663379e098a10d75e89724134e585f20ab3c","size":4910,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.2.1.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1390629245581,"_cnpm_publish_time":1390629245581,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.2.0":{"name":"underscore.db","version":"0.2.0","description":"Use JavaScript objects as databases","main":"dist/underscore.db.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","Lo-Dash","lodash","database","datastore","JSON","object"],"devDependencies":{"underscore":"~1.5.2","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-contrib-copy":"~0.5.0","grunt-cli":"~0.1.11"},"bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.2.0","dist":{"shasum":"f127a57f5ec895fd0105772e335cc5ad6aed2d08","size":4903,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.2.0.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1390625124573,"_cnpm_publish_time":1390625124573,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false},"0.1.0":{"name":"underscore.db","version":"0.1.0","description":"Use JavaScript objects as databases","main":"dist/underscore.db.js","scripts":{"test":"grunt test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/typicode/underscore.db.git"},"keywords":["JavaScript","Underscore","database","datastore","JSON","object"],"devDependencies":{"underscore":"~1.5.2","grunt":"~0.4.2","grunt-contrib-uglify":"~0.2.7","grunt-contrib-jshint":"~0.7.2","grunt-mocha-test":"~0.7.0","grunt-contrib-watch":"~0.5.3","grunt-contrib-copy":"~0.5.0","grunt-cli":"~0.1.11"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"homepage":"https://github.com/typicode/underscore.db","_id":"underscore.db@0.1.0","dist":{"shasum":"1bddecadd64ab3afcdb14ffc00638d85386cccff","size":4130,"noattachment":false,"key":"/underscore.db/-/underscore.db-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/underscore.db/download/underscore.db-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"directories":{},"publish_time":1389624847228,"_cnpm_publish_time":1389624847228,"deprecated":"Project has been renamed to underscore-db","_hasShrinkwrap":false}},"readme":"# Underscore.db [![Build Status](https://travis-ci.org/typicode/underscore.db.svg)](https://travis-ci.org/typicode/underscore.db) [![NPM version](https://badge.fury.io/js/underscore.db.svg)](http://badge.fury.io/js/underscore.db) [![Bower version](https://badge.fury.io/bo/underscore.db.svg)](http://badge.fury.io/bo/underscore.db)\n\n> Adds functions to Underscore/Lo-Dash for manipulating database-like objects.\n\nIt adds:\n* `get`\n* `insert`\n* `update`\n* `updateWhere`\n* `remove`\n* `removeWhere`\n* `save`\n* `load`\n* `createId`\n\nData can be persisted using the filesystem or localStorage.\n\n__[Live example](http://typicode.github.io/underscore.db/)__\n\n_For a full JSON database built on Lo-Dash and Underscore.db, check [LowDB](https://github.com/typicode/lowdb)._\n\n## Install\n\n__Node__\n\n```bash\n$ npm install underscore underscore.db\n```\n\n```javascript\nvar _   = require('underscore');\nvar _db = require('underscore.db');\n\n_.mixin(_db);\n```\n\n__Browser__\n\n```bash\n$ bower install underscore underscore.db\n```\n\n```html\n<script src=\"underscore.js\" type=\"text/javascript\"></script>\n<script src=\"underscore.db.js\" type=\"text/javascript\"></script>\n```\n\nTo use Underscore.db with Lo-Dash, just replace `underscore` with `lodash`\n\n## Usage example\n\nCreate an empty database object\n\n```javascript\nvar db = {\n  posts: []\n}\n```\n\nCreate a post\n\n```javascript\nvar newPost = _.insert(db.posts, {title: 'foo'});\n```\n\nDisplay database `console.log(db)`\n\n```javascript\n{\n  posts: [\n    {title: \"foo\", id: \"5ca959c4-b5ab-4336-aa65-8a197b6dd9cb\"}\n  ]\n}\n```\n\nRetrieve post using underscore.db `get` or underscore `find` method\n\n```javascript\nvar post = _.get(db.posts, newPost.id);\n\nvar post = _.find(db.posts, function(post) {\n  return post.title === 'foo'\n});\n```\n\nPersist\n\n```javascript\n_.save(db);\n```\n\n## API\n\nThe following database object is used in API examples.\n\n```javascript\nvar db = {\n  posts: [\n    {id: 1, body: 'one', published: false},\n    {id: 2, body: 'two', published: true}\n  ],\n  comments: [\n    {id: 1, body: 'foo', postId: 1},\n    {id: 2, body: 'bar', postId: 2}\n  ]\n}\n```\n\n__get(collection, id)__\n\nFinds and returns document by id or undefined.\n\n```javascript\nvar post = _.get(db.posts, 1);\n```\n\n__insert(collection, document)__\n\nAdds document to collection, sets an id and returns created document.\n\n```javascript\nvar post = _.insert(db.posts, {body: 'New post'});\n```\n\n__update(collection, id, attrs)__\n\nFinds document by id, copies properties to it and returns updated document or undefined.\n\n```javascript\nvar post = _.update(db.posts, 1, {body: 'Updated body'});\n```\n\n__updateWhere(collection, whereAttrs, attrs)__\n\nFinds documents using `_.where`, updates documents and returns updated documents or an empty array.\n\n```javascript\n// Publish all unpublished posts\nvar posts = _.updateWhere(db.posts, {published: false}, {published: true});\n```\n\n__remove(collection, id)__\n\nRemoves document from collection and returns it or undefined.\n\n```javascript\nvar comment = _.remove(db.comments, 1);\n```\n\n__removeWhere(collection, whereAttrs)__\n\nRemoves documents from collection using `_.where` and returns removed documents or an empty array.\n\n```javascript\nvar comments = _.removeWhere(db.comments, {postId: 1});\n```\n\n__save(db, [destination])__\n\nPersists database using localStorage or filesystem. If no destination is specified it will save to `db` or `./db.json`.\n\n```javascript\n_.save(db);\n_.save(db, '/some/path/db.json');\n```\n\n__load([source])__\n\nLoads database from localStorage or filesystem. If no source is specified it will load from `db` or `./db.json`.\n\n```javascript\nvar db = _.load();\nvar db = _.load('/some/path/db.json');\n```\n\n__id__\n\nOverwrite it if you want to use another id property.\n\n```javascript\n_.id = '_id';\n```\n\n__createId(collectionName, doc)__\n\nCalled by Underscore.db when a document is inserted. Overwrite it if you want to change id generation algorithm.\n\n```javascript\n_.createId = function(collectionName, doc) {\n  return collectionName + '-' + doc.name + '-' + _.random(1, 9999);\n}\n```\n\n## FAQ\n\n### How to query?\n\nEverything you need for querying is present in Underscore and Lo-Dash: `where`, ```find```, ```map```, ```reduce```, ```filter```, ```reject```, ```sortBy```, ```groupBy```, ```countBy```, ...\n\nSee http://underscorejs.org/ or http://lodash.com/docs.\n\nExample:\n\n```javascript\n// Using Underscore\nvar topFivePosts = _(db.posts)\n  .chain()\n  .where({published: true})\n  .sortBy(function(post) {\n     return post.views;\n   })\n  .first(5)\n  .value();\n\n// Using Lo-Dash\nvar topFivePosts = _(db.posts)\n  .where({published: true})\n  .sortBy('views')\n  .first(5)\n  .value();\n```\n\n### How to reduce file size?\n\nWith Lo-Dash, you can create optimal builds and include just what you need.\n\nMinimal build for Underscore.db to work (~2kb min gzipped):\n\n```bash\n$ npm install -g lodash-cli\n$ lodash underscore include=find,where,clone,indexOf\n```\n\nFor more build options, see http://lodash.com/custom-builds.\n\n## License\n\nUnderscore.db is released under the MIT License.","_attachments":{},"homepage":"https://github.com/typicode/underscore.db","bugs":{"url":"https://github.com/typicode/underscore.db/issues"},"license":"MIT"}