{"id":14975658,"url":"https://github.com/riyadhalnur/mongoose-softdelete","last_synced_at":"2025-10-27T14:31:03.763Z","repository":{"id":15562270,"uuid":"18297502","full_name":"riyadhalnur/mongoose-softdelete","owner":"riyadhalnur","description":"Soft delete MongoDB documents","archived":false,"fork":false,"pushed_at":"2023-02-01T02:22:49.000Z","size":679,"stargazers_count":40,"open_issues_count":7,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T06:11:46.856Z","etag":null,"topics":["javascript","mongodb","mongoose","mongoose-plugin"],"latest_commit_sha":null,"homepage":"http://riyadhalnur.github.io/mongoose-softdelete","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/riyadhalnur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["paypal.me/riyadhalnur"]}},"created_at":"2014-03-31T15:10:00.000Z","updated_at":"2024-04-07T19:57:43.000Z","dependencies_parsed_at":"2023-02-17T01:15:49.376Z","dependency_job_id":null,"html_url":"https://github.com/riyadhalnur/mongoose-softdelete","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fmongoose-softdelete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fmongoose-softdelete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fmongoose-softdelete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fmongoose-softdelete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riyadhalnur","download_url":"https://codeload.github.com/riyadhalnur/mongoose-softdelete/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508738,"owners_count":19484195,"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":["javascript","mongodb","mongoose","mongoose-plugin"],"created_at":"2024-09-24T13:52:21.114Z","updated_at":"2025-10-27T14:31:03.751Z","avatar_url":"https://github.com/riyadhalnur.png","language":"JavaScript","funding_links":["paypal.me/riyadhalnur"],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/riyadhalnur/mongoose-softdelete.svg?branch=master)](https://travis-ci.org/riyadhalnur/mongoose-softdelete)\n\n# Project Archival\nThis project will be archived and the NPM package will be marked as deprecated. If you are using this package, look into migrating to [Mongoose Delete](https://github.com/dsanel/mongoose-delete) by [Sanel Deljkic](https://github.com/dsanel) which is still supported and is under [consideration](https://github.com/dsanel/mongoose-delete/issues/159) to be accepted\nas an official Mongoose plugin.\n\n# Mongoose Soft Delete Plugin\n\nMongoose plugin that enables soft deletion of Models/Documents.\n\nThis plugin is based on the work of [Yi](https://github.com/yi).\n\n## What's Different\n\nIn the original plugin, models were deleted with a date reference only. This version takes that and uses a Boolean flag to to mark models deleted/restored. Adds `deletedAt` field to record when a document was deleted. Additionally, it removes a lot of overhead from the original code and doesn't use Coffeescript.\n\nAlso checkout [Mongoose Delete](https://github.com/dsanel/mongoose-delete) by [Sanel Deljkic](https://github.com/dsanel).\n\n## License\n\nThis plugin is licensed under the MIT license and can ve viewed in the LICENSE file.\n\n## Installation\n\nInstall using [npm](https://npmjs.org)\n\n```\nnpm install mongoose-softdelete --save\n```\n\n## Tests\n\nIMPORTANT: You need to have MongoDB running to run tests\n\n```\nnpm test\n```\n\n## Usage\n\n**models/test.js**\n\n```js\nconst mongoose = require('mongoose'),\n    Schema = mongoose.Schema,\n    soft_delete = require('mongoose-softdelete');\n\nconst TestSchema = new Schema({\n  somefield: { type: String, default: 'Hello World!' },\n});\n\nTestSchema.plugin(soft_delete);\n\nmongoose.model('Test', TestSchema);\n```\n\n**controllers/test.js**\n\n```js\nconst Test = mongoose.model('Test');\nconst test = new Test();\n\ntest.softdelete(function (err, newTest) {\n  if (err) {\n    callback(err);\n  }\n  callback(null, newTest);\n});\n\ntest.restore(function (err, newTest) {\n  if (err) {\n    callback(err);\n  }\n  callback(null, newTest);\n});\n\n// chainable query method\n// defaults to true unless specified\nTest.find().isDeleted(false).exec();\n```\n\n## Typescript\n\n```ts\nimport { Schema, model } from 'mongoose';\nimport softdelete, { ISoftDeletedDocument } from 'mongoose-softdelete';\n\ninterface ITestDocument extends ISoftDeletedDocument {\n    somefield: string;\n}\n\nconst TestSchema = new Schema({\n    somefield: { type: String, default: 'Hello World!' }\n});\n\nTestSchema.plugin(softdelete);\n\nconst Test = model\u003cITestDocument\u003e('Test', TestSchema);\nconst test1 = new Test();\n\ntest1.softdelete(function (err, newTest: ITestDocument) {\n    // ...\n});\n\n// chainable query method\n// defaults to true unless specified\n(Test.find({}) as unknown as ISoftDeletedDocumentQuery).isDeleted(false)\n```\n\n---\n\nBuilt with love in Dhaka, Bangladesh by [Riyadh Al Nur](https://twitter.com/riyadhalnur)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friyadhalnur%2Fmongoose-softdelete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friyadhalnur%2Fmongoose-softdelete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friyadhalnur%2Fmongoose-softdelete/lists"}