{"id":18926754,"url":"https://github.com/ladjs/mongoose-omit-common-fields","last_synced_at":"2025-04-15T13:33:15.737Z","repository":{"id":25382356,"uuid":"103856982","full_name":"ladjs/mongoose-omit-common-fields","owner":"ladjs","description":"Array of common fields to emit for Mongoose toObject/toJSON (helpful for security)","archived":false,"fork":false,"pushed_at":"2022-04-08T08:03:37.000Z","size":310,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T02:01:54.154Z","etag":null,"topics":["common","fields","helper","koa","lad","mongo","mongodb","mongoose","omit","security","select"],"latest_commit_sha":null,"homepage":"https://lad.js.org","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/ladjs.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":"2017-09-17T19:46:57.000Z","updated_at":"2022-09-16T22:33:49.000Z","dependencies_parsed_at":"2022-08-07T11:15:38.384Z","dependency_job_id":null,"html_url":"https://github.com/ladjs/mongoose-omit-common-fields","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmongoose-omit-common-fields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmongoose-omit-common-fields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmongoose-omit-common-fields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmongoose-omit-common-fields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladjs","download_url":"https://codeload.github.com/ladjs/mongoose-omit-common-fields/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249080466,"owners_count":21209532,"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":["common","fields","helper","koa","lad","mongo","mongodb","mongoose","omit","security","select"],"created_at":"2024-11-08T11:17:04.873Z","updated_at":"2025-04-15T13:33:15.383Z","avatar_url":"https://github.com/ladjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-omit-common-fields\n\n[![build status](https://img.shields.io/travis/ladjs/mongoose-omit-common-fields.svg)](https://travis-ci.org/ladjs/mongoose-omit-common-fields)\n[![code coverage](https://img.shields.io/codecov/c/github/ladjs/mongoose-omit-common-fields.svg)](https://codecov.io/gh/ladjs/mongoose-omit-common-fields)\n[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)\n[![license](https://img.shields.io/github/license/ladjs/mongoose-omit-common-fields.svg)](\u003c\u003e)\n\n\u003e Array of common fields to emit for Mongoose toObject/toJSON (helpful for security)\n\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n  * [Reference](#reference)\n* [API](#api)\n  * [omitCommonFields.underscored.keys](#omitcommonfieldsunderscoredkeys)\n  * [omitCommonFields.underscored.str](#omitcommonfieldsunderscoredstr)\n  * [omitCommonFields.underscored.obj](#omitcommonfieldsunderscoredobj)\n  * [omitCommonFields.underscored.objTrue](#omitcommonfieldsunderscoredobjtrue)\n  * [omitCommonFields.camelCased.keys](#omitcommonfieldscamelcasedkeys)\n  * [omitCommonFields.camelCased.str](#omitcommonfieldscamelcasedstr)\n  * [omitCommonFields.camelCased.obj](#omitcommonfieldscamelcasedobj)\n  * [omitCommonFields.camelCased.objTrue](#omitcommonfieldscamelcasedobjtrue)\n* [Tips](#tips)\n* [Contributors](#contributors)\n* [License](#license)\n\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install mongoose-omit-common-fields\n```\n\n[yarn][]:\n\n```sh\nyarn add mongoose-omit-common-fields\n```\n\n\n## Usage\n\n```js\nconst mongoose = require('mongoose');\nconst mongooseHidden = require('mongoose-hidden')();\nconst omitCommonFields = require('mongoose-omit-common-fields');\n\nconst Schema = new mongoose.Schema();\n\nSchema.plugin(\n  mongooseHidden,\n  // if your database fields are camelCased then\n  // you will need to use `omitCommonFields.camelCased` variation\n  // (e.g. `omitCommonFields.camelCased.objTrue`)\n  { hidden: omitCommonFields.underscored.objTrue }\n);\n```\n\nIf you want to add additional keys to be omitted:\n\n```js\nSchema.plugin(\n  mongooseHidden,\n  {\n    hidden: {\n      ...omitCommonFields.underscored.objTrue,\n      some_other_field: true,\n      another_field_to_ignore: true\n    }\n  }\n);\n```\n\n### Reference\n\nFor more information on `-` and object notation, please see \u003chttp://mongoosejs.com/docs/api.html#query_Query-select\u003e and \u003chttps://github.com/mblarsen/mongoose-hidden\u003e.\n\n\n## API\n\n### omitCommonFields.underscored.keys\n\n```js\n[ '_id',\n  '__v',\n  'ip',\n  'last_ips',\n  'email',\n  'api_token',\n  'group',\n  'attempts',\n  'last',\n  'hash',\n  'password',\n  'salt',\n  'reset_token_expires_at',\n  'reset_token',\n  'google_profile_id',\n  'google_access_token',\n  'google_refresh_token' ]\n```\n\n### omitCommonFields.underscored.str\n\n```js\n\"-_id -__v -ip -last_ips -email -api_token -group -attempts -last -hash -password -salt -reset_token_expires_at -reset_token -google_profile_id -google_access_token -google_refresh_token\"\n```\n\n### omitCommonFields.underscored.obj\n\n```js\n{ _id: 0,\n  __v: 0,\n  ip: 0,\n  last_ips: 0,\n  email: 0,\n  api_token: 0,\n  group: 0,\n  attempts: 0,\n  last: 0,\n  hash: 0,\n  password: 0,\n  salt: 0,\n  reset_token_expires_at: 0,\n  reset_token: 0,\n  google_profile_id: 0,\n  google_access_token: 0,\n  google_refresh_token: 0 }\n```\n\n### omitCommonFields.underscored.objTrue\n\n```js\n{ _id: true,\n  __v: true,\n  ip: true,\n  last_ips: true,\n  email: true,\n  api_token: true,\n  group: true,\n  attempts: true,\n  last: true,\n  hash: true,\n  password: true,\n  salt: true,\n  reset_token_expires_at: true,\n  reset_token: true,\n  google_profile_id: true,\n  google_access_token: true,\n  google_refresh_token: true }\n```\n\n### omitCommonFields.camelCased.keys\n\n```js\n[ 'id',\n  'v',\n  'ip',\n  'lastIps',\n  'email',\n  'apiToken',\n  'group',\n  'attempts',\n  'last',\n  'hash',\n  'password',\n  'salt',\n  'resetTokenExpiresAt',\n  'resetToken',\n  'googleProfileId',\n  'googleAccessToken',\n  'googleRefreshToken' ]\n```\n\n### omitCommonFields.camelCased.str\n\n```js\n\"-id -v -ip -lastIps -email -apiToken -group -attempts -last -hash -password -salt -resetTokenExpiresAt -resetToken -googleProfileId -googleAccessToken -googleRefreshToken\"\n```\n\n### omitCommonFields.camelCased.obj\n\n```js\n{ id: 0,\n  v: 0,\n  ip: 0,\n  lastIps: 0,\n  email: 0,\n  apiToken: 0,\n  group: 0,\n  attempts: 0,\n  last: 0,\n  hash: 0,\n  password: 0,\n  salt: 0,\n  resetTokenExpiresAt: 0,\n  resetToken: 0,\n  googleProfileId: 0,\n  googleAccessToken: 0,\n  googleRefreshToken: 0 }\n```\n\n### omitCommonFields.camelCased.objTrue\n\n```js\n{ id: true,\n  v: true,\n  ip: true,\n  lastIps: true,\n  email: true,\n  apiToken: true,\n  group: true,\n  attempts: true,\n  last: true,\n  hash: true,\n  password: true,\n  salt: true,\n  resetTokenExpiresAt: true,\n  resetToken: true,\n  googleProfileId: true,\n  googleAccessToken: true,\n  googleRefreshToken: true }\n```\n\n\n## Tips\n\nNote that this package is already built-in to [mongoose-common-plugin][].\n\n\n## Contributors\n\n| Name           | Website                    |\n| -------------- | -------------------------- |\n| **Nick Baugh** | \u003chttp://niftylettuce.com/\u003e |\n\n\n## License\n\n[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com/)\n\n\n## \n\n[npm]: https://www.npmjs.com/\n\n[yarn]: https://yarnpkg.com/\n\n[mongoose-common-plugin]: https://github.com/ladjs/mongoose-common-plugin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fmongoose-omit-common-fields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladjs%2Fmongoose-omit-common-fields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fmongoose-omit-common-fields/lists"}