Use transaction from middleware for more database queries (#6051)

This commit is contained in:
jannschu
2023-10-21 23:31:14 +02:00
committed by GitHub
parent 5df48b3204
commit 0518cdc6d9
7 changed files with 29 additions and 11 deletions

View File

@@ -33,6 +33,7 @@ router.post(
if (documentId) {
const document = await Document.findByPk(documentId, {
userId: user.id,
transaction,
});
authorize(user, "star", document);
}
@@ -40,7 +41,7 @@ router.post(
if (collectionId) {
const collection = await Collection.scope({
method: ["withMembership", user.id],
}).findByPk(collectionId);
}).findByPk(collectionId, { transaction });
authorize(user, "star", collection);
}