optimized queries
This commit is contained in:
@@ -238,7 +238,13 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
|||||||
.findOne({
|
.findOne({
|
||||||
_id: location._id,
|
_id: location._id,
|
||||||
"bills.name": billName
|
"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
|
// Only add if bill with same name doesn't already exist
|
||||||
if (!existingBill) {
|
if (!existingBill) {
|
||||||
@@ -363,7 +369,12 @@ export const deleteBillById = withUser(async (user:AuthenticatedUser, locationID
|
|||||||
if (deleteInSubsequentMonths) {
|
if (deleteInSubsequentMonths) {
|
||||||
// Get the current location and bill to find the bill name and location name
|
// Get the current location and bill to find the bill name and location name
|
||||||
const location = await dbClient.collection<BillingLocation>("lokacije")
|
const location = await dbClient.collection<BillingLocation>("lokacije")
|
||||||
.findOne({ _id: locationID, userId });
|
.findOne({ _id: locationID, userId }, {
|
||||||
|
projection: {
|
||||||
|
"bills.attachment.fileContentsBase64": 0,
|
||||||
|
"bills.barcodeImage": 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (location) {
|
if (location) {
|
||||||
const bill = location.bills.find(b => b._id === billID);
|
const bill = location.bills.find(b => b._id === billID);
|
||||||
|
|||||||
Reference in New Issue
Block a user