{"id":21277642,"url":"https://github.com/aliatech/loopback-mongo-distinct-mixin","last_synced_at":"2026-05-07T12:31:32.878Z","repository":{"id":34106921,"uuid":"170002661","full_name":"aliatech/loopback-mongo-distinct-mixin","owner":"aliatech","description":"Provide to models the ability to query distinct values from database","archived":false,"fork":false,"pushed_at":"2022-12-30T16:38:43.000Z","size":675,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-22T03:45:44.998Z","etag":null,"topics":["distinct","loopback","mixin","mongodb","node","orm"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aliatech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-10T17:04:56.000Z","updated_at":"2019-11-11T22:23:08.000Z","dependencies_parsed_at":"2023-01-15T04:45:35.427Z","dependency_job_id":null,"html_url":"https://github.com/aliatech/loopback-mongo-distinct-mixin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/aliatech/loopback-mongo-distinct-mixin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliatech%2Floopback-mongo-distinct-mixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliatech%2Floopback-mongo-distinct-mixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliatech%2Floopback-mongo-distinct-mixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliatech%2Floopback-mongo-distinct-mixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliatech","download_url":"https://codeload.github.com/aliatech/loopback-mongo-distinct-mixin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliatech%2Floopback-mongo-distinct-mixin/sbom","scorecard":{"id":183565,"data":{"date":"2025-08-11","repo":{"name":"github.com/aliatech/loopback-mongo-distinct-mixin","commit":"b614ceedb52a6275cfa08cc342c13c2b1efe9aed"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"59 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-4jwp-vfvf-657p","Warn: Project is vulnerable to: GHSA-v8w9-2789-6hhr","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-7gc6-qh9x-w6h8","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-8gh8-hqwg-xf34","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-724c-6vrf-99rq","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-gmjw-49p4-pcfm","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-48ww-j4fc-435p","Warn: Project is vulnerable to: GHSA-hwqf-gcqm-7353","Warn: Project is vulnerable to: GHSA-9h6g-pr28-7cqp","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq","Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T19:20:53.558Z","repository_id":34106921,"created_at":"2025-08-16T19:20:53.559Z","updated_at":"2025-08-16T19:20:53.559Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32737636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distinct","loopback","mixin","mongodb","node","orm"],"created_at":"2024-11-21T10:06:36.779Z","updated_at":"2026-05-07T12:31:32.860Z","avatar_url":"https://github.com/aliatech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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/@aliatech/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) =\u003e {\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) =\u003e {\n    // names = ['john', 'mary', 'anne', ...]\n  })\n  .catch((err) =\u003e {\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) =\u003e {\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) =\u003e {\n  // Do something\n});\n````\n\nUsing default property and a filter:\n\n````js\napp.models.Person.distinctValues({company: 'alia'}, (err, names) =\u003e {\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) =\u003e {\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[\u003cimg src=\"http://alialabs.com/images/logos/logo-full-big.png\" alt=\"ALIA Technologies\" height=100/\u003e](http://alialabs.com \"Go to ALIA Technologies' website\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliatech%2Floopback-mongo-distinct-mixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliatech%2Floopback-mongo-distinct-mixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliatech%2Floopback-mongo-distinct-mixin/lists"}