{"id":14975615,"url":"https://github.com/abranhe/normalize-mongoose","last_synced_at":"2025-06-28T09:36:18.892Z","repository":{"id":36679497,"uuid":"229549980","full_name":"abranhe/normalize-mongoose","owner":"abranhe","description":"Normalize Mongoose JSON output","archived":false,"fork":false,"pushed_at":"2024-07-01T07:17:15.000Z","size":34,"stargazers_count":15,"open_issues_count":7,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-14T19:17:05.339Z","etag":null,"topics":["js","mongodb","mongoose","mongoose-plugin"],"latest_commit_sha":null,"homepage":"https://p.abranhe.com/normalize-mongoose","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/abranhe.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","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},"funding":{"patreon":"abranhe","open_collective":"abranhe","custom":"https://cash.me/$abranhe"}},"created_at":"2019-12-22T10:16:45.000Z","updated_at":"2025-04-18T20:07:29.000Z","dependencies_parsed_at":"2024-05-01T08:48:14.669Z","dependency_job_id":"ded6fb3e-72c0-4279-b8b6-390bfea4d786","html_url":"https://github.com/abranhe/normalize-mongoose","commit_stats":{"total_commits":20,"total_committers":3,"mean_commits":6.666666666666667,"dds":0.35,"last_synced_commit":"3867ca08195e991f544844287109a1bcafcaebd6"},"previous_names":["abranhe/normalize-mongoose","abrahamhba/normalize-mongoose"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/abranhe/normalize-mongoose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fnormalize-mongoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fnormalize-mongoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fnormalize-mongoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fnormalize-mongoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abranhe","download_url":"https://codeload.github.com/abranhe/normalize-mongoose/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fnormalize-mongoose/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262406945,"owners_count":23306285,"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":["js","mongodb","mongoose","mongoose-plugin"],"created_at":"2024-09-24T13:52:17.415Z","updated_at":"2025-06-28T09:36:18.876Z","avatar_url":"https://github.com/abranhe.png","language":"JavaScript","funding_links":["https://patreon.com/abranhe","https://opencollective.com/abranhe","https://cash.me/$abranhe"],"categories":[],"sub_categories":[],"readme":"# normalize-mongoose\n\n[![GH Status](https://github.com/abranhe/normalize-mongoose/workflows/build/badge.svg)](https://github.com/abranhe/normalize-mongoose/actions)\n[![NPM](https://img.shields.io/npm/v/normalize-mongoose)](https://npmjs.org/normalize-mongoose)\n[![License](https://img.shields.io/npm/l/normalize-mongoose)](https://npmjs.org/normalize-mongoose)\n\n\u003e Normalize Mongoose JSON output\n\nThis plugin removes the following fields `_id`, `__v`, and published virtuals `id` when the document is converted to JSON. Also it allows you to hide private fields like `password`.\n\n## Install\n\n```\n$ npm install normalize-mongoose\n```\n\nUsing [Github NPM Registry](https://github.com/features/packages)\n\n```\n$ npm install abranhe@normalize-mongoose\n```\n\n## Usage\n\n```js\nimport mongoose from 'mongoose';\nimport normalize from 'normalize-mongoose';\n\nconst personSchema = mongoose.Schema({\n    name: String,\n    age: Number,\n});\n\npersonSchema.plugin(normalize);\n```\n\nSee how `normalize-mongoose` will clean the the JSON output:\n\n###### From:\n\n```json\n{\n  \"_id\": \"5dff03d3218b91425b9d6fab\",\n  \"name\": \"Abraham\",\n  \"__v\": 0\n}\n```\n\n###### To:\n\n```json\n{\n  \"id\": \"5dff03d3218b91425b9d6fab\",\n  \"name\": \"Abraham\"\n}\n```\n\n`normalize-mongoose` comes really handy on real word applications, allowing you to hide from the output any private field previously defined.\n\n```js\nimport mongoose from 'mongoose';\nimport normalize from 'normalize-mongoose';\n\nconst personSchema = mongoose.Schema({\n    name: String,\n    age: Number,\n    email: String,\n    password: { type: String, private: true },\n});\n\npersonSchema.plugin(normalize);\n\nconst Person = mongoose.model('Person', personSchema);\nconst someone = new Person( {\n  name: 'Abraham',\n  age: 33,\n  email: 'abranhe@example.com',\n  password: 'my_awesome_password',\n});\n```\n\nThe above code will output:\n\n```json\n{\n  \"id\": \"5dff03d3218b91425b9d6fab\",\n  \"name\": \"Abraham\",\n  \"age\": 33,\n  \"email\": \"abranhe@example.com\"\n}\n```\n\n## License\n\nMIT © [Abraham Hernandez](https://abranhe.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabranhe%2Fnormalize-mongoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabranhe%2Fnormalize-mongoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabranhe%2Fnormalize-mongoose/lists"}