locationAction: query optimization

This commit is contained in:
2025-08-11 13:58:57 +02:00
parent fade52a49f
commit daa9b2a134

View File

@@ -369,7 +369,7 @@ export const deleteLocationById = withUser(async (user:AuthenticatedUser, locati
if (deleteInSubsequentMonths) {
// Get the location name first to find all locations with the same name
const location = await dbClient.collection<BillingLocation>("lokacije")
.findOne({ _id: locationID, userId }, { projection: { bills: 0 } });
.findOne({ _id: locationID, userId }, { projection: { name: 1 } });
if (location) {
// Delete all locations with the same name in current and subsequent months