Deleting a collection should detach associated drafts from it (#5082)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Apoorv Mishra
2023-04-24 00:50:44 +05:30
committed by GitHub
parent 7250c0ed64
commit 86062f396d
39 changed files with 363 additions and 112 deletions

View File

@@ -126,7 +126,9 @@ export default async function loadDocument({
if (canReadDocument) {
// Cannot use document.collection here as it does not include the
// documentStructure by default through the relationship.
collection = await Collection.findByPk(document.collectionId);
if (document.collectionId) {
collection = await Collection.findByPk(document.collectionId);
}
if (!collection) {
throw NotFoundError("Collection could not be found for document");
}
@@ -146,7 +148,9 @@ export default async function loadDocument({
}
// It is possible to disable sharing at the collection so we must check
collection = await Collection.findByPk(document.collectionId);
if (document.collectionId) {
collection = await Collection.findByPk(document.collectionId);
}
invariant(collection, "collection not found");
if (!collection.sharing) {