{"id":16731458,"url":"https://github.com/skratchdot/mongodb-distinct-types","last_synced_at":"2025-08-21T03:16:44.105Z","repository":{"id":3158705,"uuid":"4189100","full_name":"skratchdot/mongodb-distinct-types","owner":"skratchdot","description":"Similar to the db.myCollection.distinct() function, distinctTypes() will return \"types\" rather than \"values\"","archived":false,"fork":false,"pushed_at":"2014-04-25T04:42:00.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T18:24:53.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://skratchdot.github.com/mongodb-distinct-types/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skratchdot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-01T02:42:06.000Z","updated_at":"2016-12-06T11:24:41.000Z","dependencies_parsed_at":"2022-09-06T21:21:04.761Z","dependency_job_id":null,"html_url":"https://github.com/skratchdot/mongodb-distinct-types","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/skratchdot/mongodb-distinct-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fmongodb-distinct-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fmongodb-distinct-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fmongodb-distinct-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fmongodb-distinct-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skratchdot","download_url":"https://codeload.github.com/skratchdot/mongodb-distinct-types/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fmongodb-distinct-types/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271420155,"owners_count":24756491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-12T23:37:24.411Z","updated_at":"2025-08-21T03:16:44.081Z","avatar_url":"https://github.com/skratchdot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MongoDB - distinct-types.js #\n\n[Project Page](http://skratchdot.com/projects/mongodb-distinct-types/)  \n[Source Code](https://github.com/skratchdot/mongodb-distinct-types/)  \n[Issues](https://github.com/skratchdot/mongodb-distinct-types/issues/)  \n\n## Description: ##\n\nSimilar to the db.myCollection.distinct() function, distinctTypes() will return\n\"types\" rather than \"values\".  To accomplish this, it adds the following\nfunction to the DBCollection prototype:  \n\n```javascript\nDBCollection.prototype.distinctTypes = function (keyString, query, limit, skip) {};\n```\n\n## Usage: ##\n\n```javascript\n// we hope this would return ['bson'] not ['bson','string']\ndb.users.distinctTypes('name');\n\n// should return ['string']\ndb.users.distinctTypes('name.first');\n\n// should return ['string']\ndb.users.distinctTypes('address.phone');\n\n// only search documents that have { 'name.first' : 'Bob' }\ndb.users.distinctTypes('address.phone', {'name.first':'Bob'});\n\n// only search the first 10 documents\ndb.users.distinctTypes('address.phone', {}, 10);\n\n// only search documents 10-15\ndb.users.distinctTypes('address.phone', {}, 10, 5);\n```\n\n## Caveats: ##\n\nBy design, distinctTypes() returns 'bson' rather than 'object'.\nIt will return 'numberlong' rather than 'number', etc.\n\n## Installation: ##\n\nDownload: [distinct-types.js](https://github.com/skratchdot/mongodb-distinct-types/raw/master/distinct-types.js)\n\n### Option 1 ###\n\nAdd this script to your .mongorc.js file.  \n\nSee: [http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell#Overview-TheMongoDBInteractiveShell-.mongorc.js](http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell#Overview-TheMongoDBInteractiveShell-.mongorc.js)\n\n### Option 2 ###\n\nStart the shell after executing this script  \n\n    mongo --shell distinct-types.js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Fmongodb-distinct-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskratchdot%2Fmongodb-distinct-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Fmongodb-distinct-types/lists"}