From 44cdcf8cec4e5c834dd898d145ebffa5151929f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Mon, 11 Aug 2025 12:19:29 +0200 Subject: [PATCH] optimized queries --- app/lib/actions/billActions.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/lib/actions/billActions.ts b/app/lib/actions/billActions.ts index 1d251f2..e4220af 100644 --- a/app/lib/actions/billActions.ts +++ b/app/lib/actions/billActions.ts @@ -238,7 +238,13 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI .findOne({ _id: location._id, "bills.name": billName - }, { projection: { "bills.$": 1 } }); + }, { + projection: { + "bills.$": 1, + "bills.attachment": 0, + "bills.barcodeImage": 0 + } + }); // Only add if bill with same name doesn't already exist if (!existingBill) { @@ -363,7 +369,12 @@ export const deleteBillById = withUser(async (user:AuthenticatedUser, locationID if (deleteInSubsequentMonths) { // Get the current location and bill to find the bill name and location name const location = await dbClient.collection("lokacije") - .findOne({ _id: locationID, userId }); + .findOne({ _id: locationID, userId }, { + projection: { + "bills.attachment.fileContentsBase64": 0, + "bills.barcodeImage": 0 + } + }); if (location) { const bill = location.bills.find(b => b._id === billID);