From 534955a9fa9c0176f4b52167829e547741a7a742 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 7 Dec 2025 13:38:48 +0100 Subject: [PATCH] Fix MongoDB projection error in uploadProofOfPayment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed mixed inclusion/exclusion projection that caused error: "Cannot do inclusion on field bills.proofOfPayment.uploadedAt in exclusion projection" Changed projection to use exclusion-only: - Exclude bills.attachment (not needed in upload context) - Exclude bills.proofOfPayment.fileContentsBase64 (large file data) - Include all other fields implicitly (including uploadedAt for existence check) This reduces data transfer while maintaining MongoDB projection compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/lib/actions/billActions.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/lib/actions/billActions.ts b/app/lib/actions/billActions.ts index f92d71a..c5b09fa 100644 --- a/app/lib/actions/billActions.ts +++ b/app/lib/actions/billActions.ts @@ -511,10 +511,9 @@ export const uploadProofOfPayment = async (locationID: string, billID: string, f const dbClient = await getDbClient(); const projection = { + // attachment is not required in this context - this will reduce data transfer "bills.attachment": 0, - // don't include the attachment - save the bandwidth it's not needed here - "bills.proofOfPayment.uploadedAt": 1, - // ommit only the file contents - we need to know if a file was already uploaded + // ommit file content - not needed here - this will reduce data transfer "bills.proofOfPayment.fileContentsBase64": 0, };