Don't move archive

This commit is contained in:
Saumya Pandey committed 2021-08-12 02:35:51 +05:30
1 parent 65e5030efd
commit ab5b3e151a
1 file changed
+4 -16
+4 -16
View File
@@ -197,28 +197,16 @@ Collection.associate = (models) => {
};
Collection.addHook("afterDestroy", async (model: Collection) => {
// sets deletedAt attribute of archived, templates and normal documents
// sets deletedAt attribute of templates and normal documents
await Document.destroy({
where: {
collectionId: model.id,
archivedAt: {
[Op.eq]: null,
},
},
});
// updating the documents that moved to deleted state from archived state
await Document.update(
{
archivedAt: null,
},
{
where: {
deletedAt: {
[Op.ne]: null,
},
},
paranoid: false,
}
);
// updating the drafts to have no collection
await Document.unscoped().update(
{