{"_id":"@aliatech/loopback-mongo-distinct-mixin","_rev":"3-8808407b374ac33fdd9f0d127c79ab50","name":"@aliatech/loopback-mongo-distinct-mixin","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@aliatech/loopback-mongo-distinct-mixin","version":"1.0.0","description":"Loopback mixin to provide mongo distinct queries","publishConfig":{"access":"public"},"keywords":["node","loopback","mongo","mixin"],"author":{"name":"Juan Costa","email":"juancosta@alialabs.com","url":"ALIA Technologies"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aliatech/loopback-mongo-distinct-mixin.git"},"scripts":{"lint":"eslint index.js","test":"mocha --exit"},"main":"index.js","dependencies":{"lodash":"^4.17.11","loopback-connector-mongodb":"^3.9.2"},"devDependencies":{"eslint":"^5.13.0","eslint-config-google":"^0.12.0","loopback":"^3.25.0","loopback-boot":"^2.27.1","loopback-component-explorer":"^6.3.1","loopback-testing":"^1.4.0","mocha":"^5.2.0","should":"^13.2.3","strong-error-handler":"^3.2.0"},"gitHead":"293c24ae83251ce26f26ad63619c78705090e31c","bugs":{"url":"https://github.com/aliatech/loopback-mongo-distinct-mixin/issues"},"homepage":"https://github.com/aliatech/loopback-mongo-distinct-mixin#readme","_id":"@aliatech/loopback-mongo-distinct-mixin@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"akeri","email":"juancosta@alialabs.com"},"dist":{"integrity":"sha512-OsagtAQu2Q6vyjVPGC/ce3hbWIBrLYUZkaOVNznNPXkl8oTd9vjXbgtpwicRqSlAqfaOVOWgf8ArDGA/E12vyg==","shasum":"bd5f56d4255240ced7fb314e4ad847a06bff08ba","tarball":"https://registry.npmjs.org/@aliatech/loopback-mongo-distinct-mixin/-/loopback-mongo-distinct-mixin-1.0.0.tgz","fileCount":21,"unpackedSize":133971,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcYF7CCRA9TVsSAnZWagAAc40P/i0FYlA6JIm9nR+L0LYV\n3+WiAKeHTj3OFmonFAGAr3HaYJ+lVomv44b+oiafn8CFeUFbt4nrZRv24qIG\nGOHLIEdYgfR8U1cQcGXuoID5DFtZKiQ/hfEzr7wGZbbFJjPn8jOU+vLbqlea\nxtqlJ5IMVLi97bAYO3s54M5JtDWF5XYItga3M4hzqxxKhTxvv2uSDpi1BtYO\n28p62HtajeaWtEIxyFnX8hqzJJYW+SeeAfU4s28JSFVpZJIIoWVa625KdVUm\n+/52AhpwRb4cf8fRrigx+YrqZk6T0mOwUoh+z4zcjOc22jykCRyCKM6r0Fo2\ndUcBxMv67W5p90CF3bKbqrNu2yXJObS/Hqv5gJIyVApY4JDW53yv/piJeMnE\nC9Yk22d7X//VF80A2ZRtEWhpp9jxZWMxe4OIN2+FtMG8mcy1+kOFOLlL+feG\n+qtVM/hrreiq1kq6FlpAvJ9BEWIXCa1/l8XLzc/bbYxANPRRyhEMXMW2ujAp\n0aqEiZJgewG/f1Xu4Bj2u9kiMvO1Jo9hMH6NqgCmgSvws7TkXSBpQMt4ZEwL\nFrBVPY9q9MSNR6yCIWy5nijpqn0P8wNgKdz14jE1ukTCTo6ubZFbeWtJebM1\ni3mN0Nv/G1JqVQ/m8/fsWfjCHftXVrO8kqVHmds78thV5/1qEzZD7RcZqZuO\nM2Bd\r\n=xQrB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCUrZJD31ohRDtnTRzpRQuFOtCqf3s5L8m/PJX0iYSyAAIgSKWGQ2RdvXthi9Z/q+Df4nNuRG/IQFAbFVClDm5Y6u8="}]},"maintainers":[{"name":"akeri","email":"juancosta@alialabs.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-mongo-distinct-mixin_1.0.0_1549819585767_0.8901966041808729"},"_hasShrinkwrap":false},"1.0.1":{"name":"@aliatech/loopback-mongo-distinct-mixin","version":"1.0.1","description":"Loopback mixin to provide mongo distinct queries","publishConfig":{"access":"public"},"keywords":["node","loopback","mongo","distinct","orm","mixin"],"author":{"name":"Juan Costa","email":"juancosta@alialabs.com","url":"ALIA Technologies"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aliatech/loopback-mongo-distinct-mixin.git"},"scripts":{"lint":"eslint index.js","test":"mocha","test-with-coverage":"nyc --reporter=text --reporter=text-summary mocha","publish-coverage":"nyc report --reporter=text-lcov | coveralls"},"main":"index.js","dependencies":{"lodash":"^4.17.11","loopback-connector-mongodb":"^3.9.2"},"devDependencies":{"coveralls":"^3.0.2","eslint":"^5.13.0","eslint-config-google":"^0.12.0","loopback":"^3.25.0","loopback-boot":"^2.27.1","loopback-component-explorer":"^6.3.1","loopback-testing":"^1.4.0","mocha":"^5.2.0","nyc":"^13.2.0","should":"^13.2.3","strong-error-handler":"^3.2.0"},"gitHead":"b8712fc894ee956cace9d93170fba0bfdd88c7c9","bugs":{"url":"https://github.com/aliatech/loopback-mongo-distinct-mixin/issues"},"homepage":"https://github.com/aliatech/loopback-mongo-distinct-mixin#readme","_id":"@aliatech/loopback-mongo-distinct-mixin@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"akeri","email":"juancosta@alialabs.com"},"dist":{"integrity":"sha512-2e74BF450hUyMgphNi2I6NLwhOiFpA63L/RfYOQbxZZMjRse039mCdKGPYArFnI4JO+Qgn5oAq7CMe62UHG5PQ==","shasum":"20ed104213c7c2cf8c27e59a970c2d0089112144","tarball":"https://registry.npmjs.org/@aliatech/loopback-mongo-distinct-mixin/-/loopback-mongo-distinct-mixin-1.0.1.tgz","fileCount":23,"unpackedSize":164247,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcYKSqCRA9TVsSAnZWagAAhFwQAJ3g3F3oPQcEVUCHBKeg\nsHDmO1jznViOGyEzLuDFX6sjPU0vCcB+QkuuJxzTE1n+lOGili3XJZcFScyN\nbq9qAPd431+qWS6miv73QokCWhn9/a1fJa9j5UvfIvNFIuaJl8gFfYEkIteg\nUAj+nmpKnqzFJxoZBL5U6qfRS9BZpvA2Uq43m5loBDaJzyCU9FD+FJXhU5bK\noIUw19vo+6pIVoSVJcjCc2rHCcHjFw4tEEdJ+z+eh8+1Dsw68y7eROZg0TYy\nsIHEE4K/tb33tE/iYq1ahKeBLut+PFmbxgQ3PdzkoeHXZuj0ifXyEaGVEoyc\ndbg2Fj52Q9+BjS8fu8hMWDIVi0HhqG1GETi+3fP8kJtksARrvuWiWxFtoF6F\n+6/Ah7Hark6Y61w+1wv4PmSl0YY65WDFBhBmGc6/uhHLOjnO7/KmgmtlaAGz\nknIpnJtgF8970nke0oL6XVPscFOgW7JU2Jq51u+QSU3bUhOsHfuHOZy1AK4+\neVB3aK70Q2SfTOX/EkvJZhpOwJ6F1x/PWZEjlsoxsErFhTSx0knrZEe0AeV0\npN8rlFUYGwKquYEFvn3vxf9Cg/XV1IUB59WiP14nb7u7x3sQ0JyCQ65qRzf4\nlK518QBV/aUp5EixD8xha5DOvS19WAmDrKGHHmEUc7/m9ms3yk4uuVy/Vxtw\nxyRu\r\n=dSKy\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6wlNEJImVIqmEQpJ5Z3G19Lb1eYB4u2hMU2nFuWfxjAIgJ75rZeqBorZnUghsj408rVYbSFIZoA5uuAGEKJb9JnU="}]},"maintainers":[{"name":"akeri","email":"juancosta@alialabs.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-mongo-distinct-mixin_1.0.1_1549837482157_0.509795547517512"},"_hasShrinkwrap":false},"1.1.0":{"name":"@aliatech/loopback-mongo-distinct-mixin","version":"1.1.0","description":"Loopback mixin to provide mongo distinct queries","publishConfig":{"access":"public"},"keywords":["node","loopback","mongo","distinct","orm","mixin"],"author":{"name":"Juan Costa","email":"juancosta@alialabs.com","url":"ALIA Technologies"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aliatech/loopback-mongo-distinct-mixin.git"},"scripts":{"lint":"eslint lib","lint-fix":"eslint --fix lib","test":"mocha","test-with-coverage":"nyc --reporter=text --reporter=text-summary mocha","publish-coverage":"nyc report --reporter=text-lcov | coveralls"},"main":"index.js","dependencies":{"lodash":"^4.17.11","polygoat":"^1.1.4"},"devDependencies":{"@aliatech/eslint-config-aliatech":"^0.1.2","coveralls":"^3.0.2","eslint":"^5.13.0","loopback":"^3.25.0","loopback-boot":"^2.27.1","loopback-connector-mongodb":"^3.9.2","mocha":"^5.2.0","nyc":"^13.3.0","should":"^13.2.3","strong-error-handler":"^3.2.0"},"gitHead":"9e59114e1be44aaaa1ff5fc7f5fd3b5d6bfe459f","bugs":{"url":"https://github.com/aliatech/loopback-mongo-distinct-mixin/issues"},"homepage":"https://github.com/aliatech/loopback-mongo-distinct-mixin#readme","_id":"@aliatech/loopback-mongo-distinct-mixin@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.2","_npmUser":{"name":"akeri","email":"juancosta@alialabs.com"},"dist":{"integrity":"sha512-tj5mK0cyIhsMuqzk15nSUevo7Zcz4DMU64yak+XqlTMEqvO+pO6uG4ZskSgViBYxae/WCyERL4yTS/qOIMCVhw==","shasum":"021835049e38576f0a0cd72ebda565663088778d","tarball":"https://registry.npmjs.org/@aliatech/loopback-mongo-distinct-mixin/-/loopback-mongo-distinct-mixin-1.1.0.tgz","fileCount":23,"unpackedSize":163424,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJclq+jCRA9TVsSAnZWagAAUPEP/RwscDe79F8I6BociiSs\nzziI5XovPoAMb18Hfh+AtZDZPYH1olK5k3NUYpS/u5h6YrlDoocPusSJUERU\nDyEMgEkKBHW8SbXJ8fY1xim1c54hWbzOa+k4+A3uhHDHHmu7C8l2qcVC5Nxn\nQNoPqreluZxk4ONxtz1gA6auZPHCrtvYDdDko5ci8ehgDn10/bVy0kw8dwR2\nSHMVtaYpbRtDBzYZNbwIIYJFQDOQrDyXh9HadCp7uuQvclS8LrkF0Rsp+q2h\nqrim3Id1uJa0QgAx57IZ3BzYRPl03XCgoYG4fd5wWrfxOtGoNgrMIGreJXnW\n+DT24qL0v4tew4N4avxSIWxzW4LYpd5MGSMJRdh6K58o7gQGp4Hpqz65Ll51\nc5O8WwOdyKAvX0y8rZTWBjSS/FmXJ8J5y68JdvJpddPrHnuWbm1CTN51ODA6\n0ca/IfCD/J9gmhheDTKmL7wGDbjDXPlrIS8ZMNkO8MupC1VlEXDQ9FI1Pugu\nUxe6EfXKLJ3OwWdtL/XpbQnR11KHlV+541t+QmL4OEQaksOHeOGx07Mk2jfP\nDCSsKWPSqEoRFyzoM+Oyza+17wW9hfEgqJFJUzddL1iQdzflG5+Xt7PqUQ1M\nTMrJ260gCQjOMlp7ix8Okuuh3vgRgOz37p0ja6LX4nJu797Tu3piUEE9fBDk\nX8ac\r\n=oi1d\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICmU4R4A/MBtqY0GfrlzXm1ZkU7sTCFiRprH8hNMgH+MAiEAkdh8GtSbTRjpVbONw8rCcfa1n1XWPD6ynU200LTy8ZU="}]},"maintainers":[{"name":"akeri","email":"juancosta@alialabs.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-mongo-distinct-mixin_1.1.0_1553379234457_0.4857231426502566"},"_hasShrinkwrap":false}},"time":{"created":"2019-02-10T17:26:25.575Z","1.0.0":"2019-02-10T17:26:25.898Z","modified":"2022-04-04T12:53:36.557Z","1.0.1":"2019-02-10T22:24:42.338Z","1.1.0":"2019-03-23T22:13:54.695Z"},"maintainers":[{"name":"akeri","email":"juancosta@alialabs.com"}],"description":"Loopback mixin to provide mongo distinct queries","homepage":"https://github.com/aliatech/loopback-mongo-distinct-mixin#readme","keywords":["node","loopback","mongo","distinct","orm","mixin"],"repository":{"type":"git","url":"git+https://github.com/aliatech/loopback-mongo-distinct-mixin.git"},"author":{"name":"Juan Costa","email":"juancosta@alialabs.com","url":"ALIA Technologies"},"bugs":{"url":"https://github.com/aliatech/loopback-mongo-distinct-mixin/issues"},"license":"MIT","readme":"[![Build Status](https://travis-ci.org/aliatech/loopback-mongo-distinct-mixin.svg?branch=master)](https://travis-ci.org/aliatech/loopback-mongo-distinct-mixin)\n[![Coverage Status](https://coveralls.io/repos/github/aliatech/loopback-mongo-distinct-mixin/badge.svg?branch=master)](https://coveralls.io/github/aliatech/loopback-mongo-distinct-mixin?branch=master)\n[![npm version](https://img.shields.io/npm/v/@aliatech/loopback-mongo-distinct-mixin.svg?color=blue)](https://www.npmjs.com/package/@aliatech/loopback-mongo-distinct-mixin)\n\n# Loopback Distinct mixin for MongoDB\n\nProvide to models the ability to query distinct values from database\n\nThis is a Loopback mixin to be used together with MongoDB connector.\nWorks for Loopback 2 and 3.\n\n## How to install\n\nInstall the package through NPM\n\n```bash\nnpm i -S @aliatech/loopback-mongo-distinct-mixin\n```\n\nor Yarn\n\n```bash\nyarn add --prod @aliatech/loopback-mongo-distinct-mixin\n```\n\n## Server configuration\n\nInclude the mixin in `server/model-config.json`:\n\n```json\n{\n  \"_meta\": {\n    \"sources\": [\n      \"loopback/common/models\",\n      \"loopback/server/models\",\n      \"../common/models\",\n      \"./models\"\n    ],\n    \"mixins\": [\n      \"loopback/common/mixins\",\n      \"../node_modules/loopback-mongo-distinct-mixin/lib\",\n      \"../common/mixins\"\n    ]\n  }\n}\n```\n\n## Usage\n\nEnable the mixin in your model definition, ie `person.json`.\n\n### Basic configuration\n\n```json\n{\n  \"name\": \"Person\",\n  \"properties\": {\n    \"name\": \"string\",\n    \"company\": \"string\"\n  },\n  \"mixins\": {\n    \"Distinct\": true\n  }\n}\n```\n\nNow you can query for distinct values this way:\n\n```js\napp.models.Person.distinctValues('name', (err, names) => {\n  if (err) return next(err);\n  // names = ['john', 'mary', 'anne', ...]\n});\n```\n\nOr using promise:\n\n```js\napp.models.Person.distinctValues('name')\n  .then((names) => {\n    // names = ['john', 'mary', 'anne', ...]\n  })\n  .catch((err) => {\n    // handle an error\n  });\n```\n\n### Advanced configuration\n\nEnable the mixin passing an options object instead of just true.\n\n**These are the available options:**\n\n| Option            | Type      | Required  | Description                                                                                                                                                                                                                                                                                           |\n| ------------------| ----------| --------- | ----------------- |\n| defaultProperty   | string    | optional  | Default property name to get values. With this option, it won't be required to specify property argument. |\n| remote            | object    | optional  | Customize a remote method to call distinct feature.                                                                                                                                                                                                                                                                                   |\n| remote.enabled    | boolean   | optional  | Enable a remote method for `distinctValues`. (default `false`) |\n| remote.name       | string    | optional  | Name of the remote method. (default `'distinctValues'`) |\n| remote.definition | object    | optional  | The Loopback definition of the remote method. |\n\n**Default options**\n\nThese are the default options that will be merged with the model specifics:\n\n```json\n{\n  \"remote\": {\n    \"enabled\": false,\n    \"name\": \"distinctValues\",\n    \"definition\": {\n      \"description\": \"Find objects with distinct property\",\n      \"http\": {\n        \"path\": \"/distinctValues\",\n        \"verb\": \"get\"\n      },\n      \"accepts\": [{\n        \"arg\": \"property\",\n        \"type\": \"string\",\n        \"required\": true\n      }, {\n        \"arg\": \"where\",\n        \"type\": \"object\",\n        \"required\": false\n      }],\n      \"returns\": {\n        \"arg\": \"objects\",\n        \"type\": \"array\",\n        \"root\": true\n      }\n    }\n  }\n}\n```\n\nNote that `property` argument will required only if `defaultProperty` is not set.\n\n### Advanced usage\n\n#### Call distinct values with filter.\n\n````js\napp.models.Person.distinctValues('name', {company: 'alia'}, (err, names) => {\n  // Got distinct names for objects having company = 'alia'\n});\n````\n\nNote: Filter should be MongoDB native, not Loopback\n\n#### Call distinct values using a default property.\n\n1. Configure `defaultProperty` option\n2. Call `distinctValues` omitting property argument\n\n````js\napp.models.Person.distinctValues((err, names) => {\n  // Do something\n});\n````\n\nUsing default property and a filter:\n\n````js\napp.models.Person.distinctValues({company: 'alia'}, (err, names) => {\n  // Do something\n});\n````\n\n#### Remote distinctValues\n\n1. Configure `remote.enabled` option to be true\n2. Call through the API\n\n````js\nconst request = require('request');\n\nrequest('http://localhost:3000/api/Person/distinctValues',\n  {qs: {property: 'name', where: {company: 'alia'}}},\n  (err, res, body) => {\n    if (err) return next(err);\n    if (res.statusCode === 200){\n      const names = JSON.parse(body);\n      // Do something\n    }\n});\n````\n\n# Testing\n\nInstall develop dependences\n\n````bash\nnpm i -D # If you use NPM\nyarn install # If you use Yarn\n````\n\nExecute tests\n\n````bash\nnpm test # Without coverage check\nnpm run test-with-coverage # With coverage check\n````\n\n# Credits\n\nDeveloped by\n[Juan Costa](https://github.com/Akeri \"Github's profile\")\nfor\n[ALIA Technologies](https://github.com/aliatech \"Github's profile\")\n\n[<img src=\"http://alialabs.com/images/logos/logo-full-big.png\" alt=\"ALIA Technologies\" height=100/>](http://alialabs.com \"Go to ALIA Technologies' website\")\n","readmeFilename":"README.md"}