Answer the question
In order to leave comments, you need to log in
How to do updateMany in Mongoose?
Colleagues, good time of the day, help, so to speak, who can do it) The essence of the problem is this, there is a collection in mongoDb and you need to update the documents in it, in fact, this is how the document looks
{
"_id" : ObjectId("5f20eb9e69d73c62bcc03194"),
"parseDate" : ISODate("2020-05-22T00:00:00.000Z"),
"orderId" : 1,
"order" : "SOME",
"key" : 1.09683,
"value" : 1.10082,
"income" : 1.09375,
"try" : 1.09477,
"__v" : 0
}
{
"parseDate": "2020-07-29T00:00:00.000Z",
"order" : "SOME",
"TRIP": 0.0061,
"OKS": 93.33991119881563
},
Answer the question
In order to leave comments, you need to log in
what exactly doesn't work?
db.collection.updateMany(
{ "parseDate": "2020-07-29T00:00:00.000Z", "order" : "SOME" },
{ $set: { "TRIP": 0.0061, "OKS": 93.33991119881563 } },
{ upsert: true } // если ничего не найдет, то пусть сделает новый документ БД
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question