{"id":25687106,"url":"https://github.com/holyshared/mongoose_example","last_synced_at":"2025-09-06T05:48:38.992Z","repository":{"id":51792379,"uuid":"195513279","full_name":"holyshared/mongoose_example","owner":"holyshared","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-09T23:43:06.000Z","size":17,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-20T01:30:21.987Z","etag":null,"topics":[],"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/holyshared.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-07-06T07:52:32.000Z","updated_at":"2019-07-15T13:05:24.000Z","dependencies_parsed_at":"2022-08-17T14:51:52.276Z","dependency_job_id":null,"html_url":"https://github.com/holyshared/mongoose_example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/holyshared/mongoose_example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fmongoose_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fmongoose_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fmongoose_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fmongoose_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/holyshared","download_url":"https://codeload.github.com/holyshared/mongoose_example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fmongoose_example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266862512,"owners_count":23996862,"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-07-24T02:00:09.469Z","response_time":99,"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":"2025-02-24T20:08:08.999Z","updated_at":"2025-07-24T15:15:34.770Z","avatar_url":"https://github.com/holyshared.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mongoose example\n\n## 環境構築\n\ndocker-composeをインストールして、コンテナを起動する。\n\n```\ndocker-compose up -d\n```\n\n## 実験\n\n### 実験-1\n\n~~ネストしたIDにObjectIdでの参照がある場合は、**populate**した時にドキュメントの構造が期待した状態にならない。~~  \n~~**mapReduce**で集計した結果をフェッチする場合は、気を付ける必要がある。~~\n\n**populate**の**path**が間違っていると、ドキュメントの構造が期待した状態にならない。\n\n```js\nconst query = { category: cat._id, year: 2019, month: 1 };\n// .でパスを表現しないとダメな模様\n// const options = { populate: { path: '_id', populate: { path: 'category' } } }; \nconst options = { populate: { path: '_id.category' } };\nconst report = await ReportStats.findById(query, null, options);\n```\n\n#### 期待する結果\n\n```js\n{\n  _id: {\n    category: { ... },\n    year: 2019, \n    month: 2019,\n  }\n}\n```\n\n#### 結果\n\n```js\n{ _id: [], value: 1 } // _idが配列になってしまう\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fmongoose_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fholyshared%2Fmongoose_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fmongoose_example/lists"}