Untitled
const MAX = 300 const cursor = await this.stockModel .find({ prices: { $ne: null }, }) .cursor() let document while ((document = await cursor.next())) { const increase = (document?.prices[0]?.price[0] || 0) * percent const price = increase > MAX ? (document?.prices[0]?.price[0] || 0) + MAX : (document?.prices[0]?.price[0] || 0) + increase await this.stockModel.updateOne( { _id: document._id, }, { $set: { 'prices.0.price.0': price, salePriceString: price?.toString() || '0', }, }, ) }