{"id":18523616,"url":"https://github.com/mongoosejs/mongoose-lean-getters","last_synced_at":"2025-04-07T14:15:03.330Z","repository":{"id":35022834,"uuid":"197442753","full_name":"mongoosejs/mongoose-lean-getters","owner":"mongoosejs","description":"Apply getters on lean() documents: https://mongoosejs.com/docs/tutorials/lean.html","archived":false,"fork":false,"pushed_at":"2025-02-24T21:38:55.000Z","size":85,"stargazers_count":10,"open_issues_count":1,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T12:07:54.467Z","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":"2019-07-17T18:32:01.000Z","updated_at":"2025-02-24T21:38:59.000Z","dependencies_parsed_at":"2023-01-15T12:13:27.876Z","dependency_job_id":"ed0cf3e3-4f29-40db-a796-bcc128964f91","html_url":"https://github.com/mongoosejs/mongoose-lean-getters","commit_stats":{"total_commits":41,"total_committers":7,"mean_commits":5.857142857142857,"dds":"0.31707317073170727","last_synced_commit":"f5213f0de6e94a184a1f11f5307dca09bff7ae4b"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-getters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-getters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-getters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-lean-getters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongoosejs","download_url":"https://codeload.github.com/mongoosejs/mongoose-lean-getters/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666015,"owners_count":20975788,"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:35.166Z","updated_at":"2025-04-07T14:15:03.298Z","avatar_url":"https://github.com/mongoosejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-lean-getters\nApply getters on lean() documents: https://mongoosejs.com/docs/tutorials/lean.html\n\nThis package requires Mongoose `\u003e= 7.1.0`. Do not use with Mongoose 7.0.x or 6.x.\n\n## Usage\n\n```javascript\nconst mongoose = require('mongoose');\nconst mongooseLeanGetters = require('mongoose-lean-getters');\n\nconst schema = mongoose.Schema({\n  name: {\n    type: String,\n    // Get the last 6 characters of the string\n    get: v =\u003e v.slice(-6)\n  }\n});\n// Add this plugin to apply getters when using `lean()`.\nschema.plugin(mongooseLeanGetters);\n\nawait Model.create({ name: 'Captain Jean-Luc Picard' });\n\nconst doc = await Model.findOne().lean({ getters: true });\ndoc.name; // 'Picard'\n```\n\nYou may also set the default lean options to always use getters:\n\n```javascript\nconst mongoose = require('mongoose');\nconst mongooseLeanGetters = require('mongoose-lean-getters');\n\nconst schema = mongoose.Schema({\n  name: {\n    type: String,\n    // Get the last 6 characters of the string\n    get: v =\u003e v.slice(-6)\n  }\n});\n// Set the default options for all lean queries\nschema.plugin(mongooseLeanGetters, { defaultLeanOptions: { getters: true }});\n\nawait Model.create({ name: 'Captain Jean-Luc Picard' });\n\nconst doc = await Model.findOne().lean();\ndoc.name; // 'Picard'\n\n// You may also set getters: false at call time\nconst doc2 = await Model.findOne().lean({ getters: false });\ndoc2.name; // 'Captain Jean-Luc Picard'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-lean-getters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongoosejs%2Fmongoose-lean-getters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-lean-getters/lists"}