{"id":18523595,"url":"https://github.com/mongoosejs/mongoose-lean-id","last_synced_at":"2025-10-15T10:07:48.027Z","repository":{"id":57302115,"uuid":"78309407","full_name":"mongoosejs/mongoose-lean-id","owner":"mongoosejs","description":"Attach `id` to the results of mongoose queries when using `.lean()`","archived":false,"fork":false,"pushed_at":"2023-12-01T02:15:44.000Z","size":27,"stargazers_count":25,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T16:07:21.895Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongoosejs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-07T23:17:45.000Z","updated_at":"2024-09-08T00:52:05.000Z","dependencies_parsed_at":"2024-06-18T18:37:18.430Z","dependency_job_id":null,"html_url":"https://github.com/mongoosejs/mongoose-lean-id","commit_stats":null,"previous_names":["vkarpov15/mongoose-lean-id"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongoosejs","download_url":"https://codeload.github.com/mongoosejs/mongoose-lean-id/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248031507,"owners_count":21036417,"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","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-11-06T17:36:24.915Z","updated_at":"2025-10-15T10:07:42.998Z","avatar_url":"https://github.com/mongoosejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-lean-id\n\nAttach `id` to the results of mongoose queries when using `.lean()`\n\n## Usage\n\n```javascript\nconst mongooseLeanId = require('mongoose-lean-id');\n```\n\n\n# examples\n\n## It attaches `.id` to result of find, findOne, and findOneAndUpdate if lean\n\n```javascript\n\n    const schema = new mongoose.Schema({\n      name: String\n    });\n\n    schema.plugin(mongooseLeanId);\n\n    const Model = mongoose.model('Test', schema);\n\n    return Model.create({ name: 'test' }).\n      then(() =\u003e Promise.all([\n        Model.find().lean(),\n        Model.findOne().lean(),\n        Model.findOneAndUpdate({}, { name: 'test' }).lean()\n      ])).\n      then(results =\u003e {\n        const [findRes, findOneRes, findOneAndUpdateRes] = results;\n        assert.equal(findRes[0].id, findRes[0]._id.toHexString());\n        assert.equal(findOneRes.id, findOneRes._id.toHexString());\n        assert.equal(findOneAndUpdateRes.id,\n          findOneAndUpdateRes._id.toHexString());\n      });\n  \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-lean-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongoosejs%2Fmongoose-lean-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-lean-id/lists"}