how can i update values to an document,where the document is an array ?
db.get().collection(collection.CATEGORY_OFFER).insertOne(data).then(async(response)=>{ let product = await db.get().collection(collection.PRODUCT_COLLECTION).find({Category:catName}).toArray() console.log(product) var bulkOp = db.get().collection(collection.PRODUCT_COLLECTION).initializeOrderedBulkOp();
var count = 0;
db.get().collection(collection.PRODUCT_COLLECTION).find().forEach(function(doc){
console.log("first")
console.log(catName)
console.log(catOffer)
console.log(parseInt(doc.Prize)-parseInt(doc.Prize*catOffer/100))
bulkOp.find({Category:catName}).updateOne({
$set:{
offer:true,
oldPrize:parseInt(doc.Prize),
value:catOffer,
Prize:(parseInt(doc.Prize)-parseInt(doc.Prize*catOffer/100)).toFixed(0)
}
})
count++;
if(count % product.length === 0){
console.log("second")
console.log(product.length)
bulkOp.execute();
bulkOp =db.get().collection(collection.PRODUCT_COLLECTION).initializeOrderedBulkOp();
console.log("helo world")
console.log(bulkOp)
}
})
if(count > 0 ){
console.log("third")
bulkOp.execute();
}
console.log("fifth")
console.log(bulkOp)
console.log(product)
})