{"_id":"lodash-id","_rev":"385218","name":"lodash-id","description":"Use JavaScript objects as databases","dist-tags":{"latest":"0.14.1"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"time":{"modified":"2021-08-04T03:09:26.000Z","created":"2017-02-20T22:39:04.967Z","0.14.1":"2021-06-09T02:49:13.537Z","0.14.0":"2017-03-14T22:25:22.980Z","0.13.0":"2017-02-20T22:39:04.967Z"},"users":{},"author":{"name":"Typicode","email":"typicode@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/typicode/lodash-id.git"},"versions":{"0.14.1":{"name":"lodash-id","version":"0.14.1","description":"Use JavaScript objects as databases","main":"src/index.js","scripts":{"test":"mocha && standard && pkg-ok","prepush":"npm test","prepublish":"npm test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/typicode/lodash-id.git"},"keywords":["lodash","lowdb","underscore","id","resource","mixin"],"devDependencies":{"husky":"^0.11.8","lodash":"^4.6.1","mocha":"^3.2.0","pkg-ok":"^1.0.1","sinon":"~1.8.1","standard":"^8.6.0","underscore":"^1.8.3","webpack":"^2.2.1"},"engines":{"node":">= 4"},"standard":{"fix":true,"env":{"mocha":true}},"gitHead":"9d3fc01c17855cf51bf4d6f255787f92412ee815","bugs":{"url":"https://github.com/typicode/lodash-id/issues"},"homepage":"https://github.com/typicode/lodash-id#readme","_id":"lodash-id@0.14.1","_nodeVersion":"16.2.0","_npmVersion":"7.15.0","dist":{"shasum":"dffa1f1f8b90d1803bb0d70b7d7547e10751e80b","size":4226,"noattachment":false,"key":"/lodash-id/-/lodash-id-0.14.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/lodash-id/download/lodash-id-0.14.1.tgz"},"_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"directories":{},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lodash-id_0.14.1_1623206953412_0.8508626021740429"},"_hasShrinkwrap":false,"publish_time":1623206953537,"_cnpm_publish_time":1623206953537},"0.14.0":{"name":"lodash-id","version":"0.14.0","description":"Use JavaScript objects as databases","main":"src/index.js","scripts":{"test":"mocha && standard && pkg-ok","prepush":"npm test","prepublish":"npm test"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/typicode/lodash-id.git"},"keywords":["lodash","lowdb","underscore","id","resource","mixin"],"devDependencies":{"husky":"^0.11.8","lodash":"^4.6.1","mocha":"^3.2.0","pkg-ok":"^1.0.1","sinon":"~1.8.1","standard":"^8.6.0","underscore":"^1.8.3","webpack":"^2.2.1"},"engines":{"node":">= 4"},"standard":{"fix":true,"env":{"mocha":true}},"gitHead":"adf8c8e99e598c448e6db6ec5705de9d9edb96ed","bugs":{"url":"https://github.com/typicode/lodash-id/issues"},"homepage":"https://github.com/typicode/lodash-id#readme","_id":"lodash-id@0.14.0","_shasum":"baf48934e543a1b5d6346f8c84698b1a8c803896","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.2","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"dist":{"shasum":"baf48934e543a1b5d6346f8c84698b1a8c803896","size":4647,"noattachment":false,"key":"/lodash-id/-/lodash-id-0.14.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/lodash-id/download/lodash-id-0.14.0.tgz"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/lodash-id-0.14.0.tgz_1489530322395_0.7156153141986579"},"directories":{},"publish_time":1489530322980,"_cnpm_publish_time":1489530322980,"_hasShrinkwrap":false},"0.13.0":{"name":"lodash-id","version":"0.13.0","description":"Use JavaScript objects as databases","main":"src/node.js","scripts":{"test":"grunt test","build":"grunt","prepush":"npm test","prepublish":"npm run build && pkg-ok"},"author":{"name":"Typicode","email":"typicode@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/typicode/lodash-id.git"},"keywords":["underscore","lodash","mixin","database"],"devDependencies":{"grunt":"~0.4.2","grunt-browserify":"^3.8.0","grunt-cli":"~0.1.11","grunt-contrib-jshint":"~0.7.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"~0.5.3","grunt-mocha-test":"~0.7.0","husky":"^0.11.8","lodash":"^4.6.1","pkg-ok":"^1.0.1","sinon":"~1.8.1","underscore":"^1.8.3"},"gitHead":"1929f719928a1b772111ee92c124edc7c6a88d9b","bugs":{"url":"https://github.com/typicode/lodash-id/issues"},"homepage":"https://github.com/typicode/lodash-id#readme","_id":"lodash-id@0.13.0","_shasum":"1b2086c24f004f07411bdb09b775072114bcddc6","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.3","_npmUser":{"name":"typicode","email":"typicode@gmail.com"},"dist":{"shasum":"1b2086c24f004f07411bdb09b775072114bcddc6","size":5254,"noattachment":false,"key":"/lodash-id/-/lodash-id-0.13.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/lodash-id/download/lodash-id-0.13.0.tgz"},"maintainers":[{"name":"typicode","email":"typicode@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/lodash-id-0.13.0.tgz_1487630343101_0.5395266907289624"},"directories":{},"publish_time":1487630344967,"_cnpm_publish_time":1487630344967,"_hasShrinkwrap":false}},"readme":"# lodash-id [![Build Status](https://travis-ci.org/typicode/lodash-id.svg)](https://travis-ci.org/typicode/lodash-id) [![NPM version](https://badge.fury.io/js/lodash-id.svg)](http://badge.fury.io/js/lodash-id)\n\n> `lodash-id` makes it easy to manipulate id-based resources with [lodash](https://lodash.com/) or [lowdb](https://github.com/typicode/lowdb)\n\n* `getById`\n* `insert`\n* `upsert`\n* `updateById`\n* `updateWhere`\n* `replaceById`\n* `removeById`\n* `removeWhere`\n* `createId`\n\n## Install\n\n```bash\n# with lodash\nnpm install lodash lodash-id --save\n\n# with lowdb\nnpm install lowdb lodash-id --save\n```\n\n__Note__ `lodash-id` is also compatible with [underscore](http://underscorejs.org/)\n\n## API\n\nIn the API examples, we're assuming `db` to be:\n\n```js\nconst 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__getById(collection, id)__\n\nFinds and returns document by id or undefined.\n\n```js\nconst post = _.getById(db.posts, 1)\n```\n\n__insert(collection, document)__\n\nAdds document to collection, sets an id and returns created document.\n\n```js\nconst post = _.insert(db.posts, { body: 'New post' })\n```\n\nIf the document already has an id, and it is the same as an existing document in the collection, an error is thrown.\n\n```js\n_.insert(db.posts, { id: 1, body: 'New post' })\n_.insert(db.posts, { id: 1, title: 'New title' }) // Throws an error\n```\n\n__upsert(collection, document)__\n\nAdds document to collection, sets an id and returns created document.\n\n```js\nconst post = _.upsert(db.posts, { body: 'New post' })\n```\n\nIf the document already has an id, it will be used to insert or replace.\n\n```js\n_.upsert(db.posts, { id: 1, body: 'New post' })\n_.upsert(db.posts, { id: 1, title: 'New title' })\n_.getById(db.posts, 1) // { id: 1, title: 'New title' }\n```\n\n__updateById(collection, id, attrs)__\n\nFinds document by id, copies properties to it and returns updated document or undefined.\n\n```js\nconst post = _.updateById(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```js\n// Publish all unpublished posts\nconst posts = _.updateWhere(db.posts, { published: false }, { published: true })\n```\n\n__replaceById(collection, id, attrs)__\n\nFinds document by id, replaces properties and returns document or undefined.\n\n```js\nconst post = _.replaceById(db.posts, 1, { foo: 'bar' })\n```\n\n__removeById(collection, id)__\n\nRemoves document from collection and returns it or undefined.\n\n```js\nconst comment = _.removeById(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```js\nconst comments = _.removeWhere(db.comments, { postId: 1 })\n```\n\n__id__\n\nOverwrite it if you want to use another id property.\n\n```js\n_.id = '_id'\n```\n\n__createId(collectionName, doc)__\n\nCalled by lodash-id when a document is inserted. Overwrite it if you want to change id generation algorithm.\n\n```js\n_.createId = (collectionName, item) => `${collectionName}-${item.prop}-${Date.now()}`\n```\n\n## Changelog\n\nSee details changes for each version in the [release notes](https://github.com/typicode/lodash-id/releases).\n\n## License\n\nMIT - [Typicode :cactus:](https://github.com/typicode)\n","_attachments":{},"homepage":"https://github.com/typicode/lodash-id#readme","bugs":{"url":"https://github.com/typicode/lodash-id/issues"},"license":"MIT"}