I added indexes for both franchiseProductId and storeId.
My previous code was like that and it was working with 3-4 seconds delay.
products.update({franchiseProductId: r.productId, storeId: product.storeId}, {$inc: {stockStore: -r.productAmount * amount}})
Than i changed it with this, it’s working without delay. i don’t know why.
let p = products.find({franchiseProductId: r.productId, storeId: product.storeId});
products.update(p._id, {$inc: {stockStore: -r.productAmount * amount}})
Can anybody explain?