Untitled
unknown
plain_text
3 years ago
741 B
7
Indexable
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',
},
},
)
}
Editor is loading...