fix: Deleting a collection should not deleted archived documents within it automatially (#1776)

closes #1775
This commit is contained in:
Tom Moor
2021-01-07 19:46:12 -08:00
committed by GitHub
parent cbfa25fa2f
commit 34598b317d
3 changed files with 45 additions and 8 deletions

View File

@ -2,7 +2,7 @@
import { find, findIndex, concat, remove, uniq } from "lodash";
import randomstring from "randomstring";
import slug from "slug";
import { DataTypes, sequelize } from "../sequelize";
import { Op, DataTypes, sequelize } from "../sequelize";
import CollectionUser from "./CollectionUser";
import Document from "./Document";
@ -182,6 +182,9 @@ Collection.addHook("afterDestroy", async (model: Collection) => {
await Document.destroy({
where: {
collectionId: model.id,
archivedAt: {
[Op.eq]: null,
},
},
});
});