{"id":14975731,"url":"https://github.com/jbutko/mongoose-patch-update","last_synced_at":"2026-02-05T20:06:10.133Z","repository":{"id":57302165,"uuid":"86988420","full_name":"jbutko/mongoose-patch-update","owner":"jbutko","description":"mongoose-patch-update plugin is simple mongoose plugin that enables model updates in PATCH like style - only what you send in body params will be updated.","archived":false,"fork":false,"pushed_at":"2017-08-08T19:16:15.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T11:22:18.201Z","etag":null,"topics":["mongodb","mongoose","mongoosejs","npm","npm-package"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbutko.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}},"created_at":"2017-04-02T13:35:08.000Z","updated_at":"2018-05-05T21:35:16.000Z","dependencies_parsed_at":"2022-09-20T14:53:59.652Z","dependency_job_id":null,"html_url":"https://github.com/jbutko/mongoose-patch-update","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jbutko/mongoose-patch-update","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbutko%2Fmongoose-patch-update","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbutko%2Fmongoose-patch-update/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbutko%2Fmongoose-patch-update/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbutko%2Fmongoose-patch-update/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbutko","download_url":"https://codeload.github.com/jbutko/mongoose-patch-update/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbutko%2Fmongoose-patch-update/sbom","scorecard":{"id":510839,"data":{"date":"2025-08-11","repo":{"name":"github.com/jbutko/mongoose-patch-update","commit":"a797fb9b88d861182ff0adf3afed7ce63dd954a7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 1/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Do What The F*ck You Want To Public License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T00:29:55.961Z","repository_id":57302165,"created_at":"2025-08-20T00:29:55.961Z","updated_at":"2025-08-20T00:29:55.961Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29132588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T19:36:52.185Z","status":"ssl_error","status_checked_at":"2026-02-05T19:35:40.941Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["mongodb","mongoose","mongoosejs","npm","npm-package"],"created_at":"2024-09-24T13:52:27.525Z","updated_at":"2026-02-05T20:06:10.115Z","avatar_url":"https://github.com/jbutko.png","language":"JavaScript","readme":"Mongoose Patch Update Plugin\n=========\n\n[![NPM](https://nodei.co/npm/mongoose-patch-update.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/mongoose-patch-update/)\n\n*mongoose-patch-update* plugin is simple [mongoose](http://www.mongoose.com) plugin that enables model updates in PATCH like style - only what you send in body params will be updated. You can set protected keys which won't be updatable.\n\n## Installation\n```\nnpm install mongoose-patch-update --save\n```\n\nYou can use this plugin with specific schema or globally for all schemas.\u003cbr /\u003e\nTo use it with specific schema:\n```javascript\nconst mongoosePatchUpdate = require('mongoose-patch-update');\n\nconst userSchema = new Schema({...});\n\n// attach mongoose-patch-update plugin to userSchema\nuserSchema.plugin(mongoosePatchUpdate);\n```\n\nTo use this plugin globally for all schemas:\n```javascript\nconst mongoose = require('mongoose');\nconst mongoosePatchUpdate = require('mongoose-patch-update');\n\nmongoose.plugin(mongoosePatchUpdate);\n```\nAfter attaching mongoose-patch-update plugin you will have `Model.patchUpdate(...)` method on your model.\n\n\n## Usage\n\n*Mongoose patch update* plugin provides support for both promise style queries as well as callback style queries.\n\n### Promise example\n```javascript\nconst mongoose = require('mongoose');\nconst ObjectId = mongoose.Types.ObjectId;\nconst User = require('./user.model.js'); // model\n\nlet query = { _id: ObjectId(req.params.userId) }; // find query\nlet updateParams = { username: 'johndoe-123', email: 'john123@doe.com' }; // update parameters - only `username` will be updated, `email` is protected\nlet protectedKeys = ['email']; // protected keys - given keys won't be allowed to be updated\nlet selectedKeys = ''; // which keys will be returned after successful update - all keys will be returned\n\n// user before update\n/*\nlet user = {\n  username: 'johndoe',\n  firstname: 'John',\n  surname: 'Doe',\n  email: 'john@doe.com'\n};\n */\n\nUser\n  .patchUpdate(\n    query,\n    updateParams,\n    protectedKeys,\n    selectedKeys\n  )\n  .then((updatedUser) =\u003e {\n    // user after update\n    /*\n    let user = {\n      username: 'johndoe-123',\n      firstname: 'John',\n      surname: 'Doe',\n      email: 'john@doe.com'\n    };\n     */\n\n    res.status(200).json(updatedUser);\n  })\n  .catch((err) =\u003e {\n    next(err);\n  });\n\n```\n\n### Callback example\n```javascript\nconst mongoose = require('mongoose');\nconst ObjectId = mongoose.Types.ObjectId;\nconst User = require('./user.model.js'); // model\n\nlet query = { _id: ObjectId(req.params.userId) }; // find query\nlet updateParams = { username: 'johndoe-123', email: 'john123@doe.com' }; // update parameters - only `username` will be updated, `email` is protected\nlet protectedKeys = ['email']; // protected keys - given keys won't be allowed to be updated\nlet selectedKeys = ''; // which keys will be returned after successful update - all keys will be returned\n\n// user before update\n/*\nlet user = {\n  username: 'johndoe',\n  firstname: 'John',\n  surname: 'Doe',\n  email: 'john@doe.com'\n};\n */\n\nUser\n  .patchUpdate(\n    query,\n    updateParams,\n    protectedKeys,\n    selectedKeys,\n  (err, updatedUser) =\u003e {\n    if (err) return next(err);\n\n    // user after update\n    /*\n    let user = {\n      username: 'johndoe-123',\n      firstname: 'John',\n      surname: 'Doe',\n      email: 'john@doe.com'\n    };\n     */\n\n    res.status(200).json(updatedUser);\n  });\n\n```\n\n## License\n\nDO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\nVersion 2, December 2004\n\nCopyright (C) 2017 Jozef Butko \u003cjbutko@gmail.com\u003e\n\nEveryone is permitted to copy and distribute verbatim or modified\ncopies of this license document, and changing it is allowed as long\nas the name is changed.\n\nDO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\nTERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n0. You just DO WHAT THE FUCK YOU WANT TO.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbutko%2Fmongoose-patch-update","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbutko%2Fmongoose-patch-update","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbutko%2Fmongoose-patch-update/lists"}