简体   繁体   English

MongoDB中的软删除过程

[英]Soft Delete Procedure in MongoDB

We are going to develop multi tenant based project, based on Java Spring Boot at backend and MongoDb as a database. 我们将基于后端的Java Spring Boot和作为数据库的MongoDb开发基于多租户的项目。

I want to ask that is there any procedure to make soft delete other than insert a attribute true/false or 0/1 ? 我想问问,除了插入属性true / false或0/1之外,还有什么程序可以进行软删除?

Thanks for the help... 谢谢您的帮助...

If you don't want to delete or use an attribute as a isDeleted or similar name. 如果您不想删除属性或将属性用作isDeleted或类似名称。 You have to move deleted documents to another collection namely deletedCollections and hard delete the current document from the current collection. 您必须将已删除的文档移动到另一个集合,即deletedCollections然后从当前集合中硬删除当前文档。 This methodology can be useful to manage these unwanted or deleted data for current collection. 此方法可用于管理这些不想要的或已删除的数据以进行当前收集。

  1. First create a another collection may be in another server or file system named as deletedCollection 首先创建另一个集合可能位于另一个服务器或文件系统中,命名为DeletedCollection
  2. First insert the document to this collection to be deleted 首先将文档插入此要删除的集合中
  3. Then delete the current document from current collection 然后从当前集合中删除当前文档

This way is useful to reach the deleted or archived data in another time. 这种方法对于再次访问已删除或已归档的数据很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM