{"id":14975529,"url":"https://github.com/euqen/mongoose-paranoid-plugin","last_synced_at":"2025-10-27T14:30:21.637Z","repository":{"id":44908709,"uuid":"112971439","full_name":"euqen/mongoose-paranoid-plugin","owner":"euqen","description":":rocket: Simple, lightweight and easy to use mongoose soft deletion plugin :rocket:","archived":false,"fork":false,"pushed_at":"2022-01-23T20:17:50.000Z","size":17,"stargazers_count":20,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T05:51:09.560Z","etag":null,"topics":["mongodb","mongoose","mongoose-plugin","mongoosejs","sequelize"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/euqen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-03T23:05:10.000Z","updated_at":"2024-10-08T16:12:41.000Z","dependencies_parsed_at":"2022-08-26T09:10:58.847Z","dependency_job_id":null,"html_url":"https://github.com/euqen/mongoose-paranoid-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euqen%2Fmongoose-paranoid-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euqen%2Fmongoose-paranoid-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euqen%2Fmongoose-paranoid-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euqen%2Fmongoose-paranoid-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/euqen","download_url":"https://codeload.github.com/euqen/mongoose-paranoid-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508424,"owners_count":19484132,"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":["mongodb","mongoose","mongoose-plugin","mongoosejs","sequelize"],"created_at":"2024-09-24T13:52:10.244Z","updated_at":"2025-10-27T14:30:21.279Z","avatar_url":"https://github.com/euqen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e:rocket: Mongoose Paranoid Plugin :rocket:\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eBuilt with ❤︎ by\n  \u003ca href=\"https://github.com/euqen\"\u003eEugene Shilin\u003c/a\u003e and\n  \u003ca href=\"https://github.com/euqen/mongoose-paranoid-plugin/graphs/contributors\"\u003e\n    contributors\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\nThis plugin allows to apply soft deletion of mongo db documents. It's simple, lightweight and easy to use. Inspired by Sequelize.\n\n## Philosophy\n\nAll existing soft deletion plugins don't allow to disable quering by non-deleted documents. They all require to use their own-implemented methods. Sometimes you need to get all documents including deleted, sometimes you need to retrieve only non-deleted. All existing plugins provide their own separate methods to do this. It's not flexible, you need to call different methods depending on situations you faced with. Introducing soft deletion plugin, it's hide all deleted documents by default, but you are able to find all documents including deleted in several ways. See usage section\n\n## Installation\n\nInstall using npm\n\n```\nnpm install mongoose-paranoid-plugin\n```\n\n## Usage\n\n### Enable plugin\n\n```\nconst mongoose = require('mongoose');\nconst mongooseParanoidPlugin = require('mongoose-paranoid-plugin');\n\nmongoose.plugin(mongooseParanoidPlugin, { field: 'deleted_at' })\n\n```\n\nOptions:\n\n- field: String. Column name which is used to store timestamp of deletion. Default value is 'deletedAt'\n\n### Using in schemas\n\nBy default this plugin won't override any methods. To enable soft deletion of your document's you need to pass `paranoid` option into your model options.\n\n```\nconst mongoose = require('mongoose');\n\nconst schema = new mongoose.Schema({\n  firstName: { type: String },\n  lastName: { type: String }\n}, {\n  paranoid: true,\n});\n\nconst User = meta.model('users', schema);\n```\n\nThis will enable soft deletion of your documents. All deleted models will be marked with `deletedAt` field by default and will not be retrieved by built-in mongoose methods. If you need to include deleted documents you need pass an attribute `{ paranoid: false }` to query options.\n\n\n```\nreturn User.find(query, {}, { paranoid: false });\n```\n\n### Soft deletion behavior\n\nThe behavior of remove method is also very explicit. If you enabled soft deletion in your schema, `remove` method will mark the document with deletedAt field. Otherwise the document will be completely removed. You can also use `paranoid` method before removing to enable/disable soft deletion.\n\n\n## Copyright\n\nCopyright (c) 2017 Eugene Shilin See LICENSE for further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuqen%2Fmongoose-paranoid-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feuqen%2Fmongoose-paranoid-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuqen%2Fmongoose-paranoid-plugin/lists"}