I have a products
collection where some products have this structure :
{
_id: anID
shops:
[
{
_id : shopId,
price: productsPrice
},
...
]
}
I would like update the price of a given products and shop, but insert this shop with his price if it is not present in the array.
I'm a beginner with MongoDB.Working with Node.Js/express(mongoDB driver) but not using mongoose.
Thanks in advance
Copyright Notice:Content Author:「apinot」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59846498/how-to-insert-or-update-an-a-array-in-mongodb-with-node-js