Fix MongoDB projection error in uploadProofOfPayment

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 <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2025-12-07 13:38:48 +01:00
parent 65b5a1cdd5
commit 534955a9fa

View File

@@ -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,
};