Answer the question
In order to leave comments, you need to log in
What is the correct way to update a large number of mongodb documents?
Maybe someone can help with the problem.
It is necessary to bypass about 100k+ documents every day, collect information and update them, this is done in order to obtain a certain rating of documents.
In terms of execution time, it is not so critical, but I would like to somehow sort out the records without heavy loads on the server.
For example, there is a prepared data array, say with 100k elements
[
_id: ObjectId(....) // ID документа которой необходимо обновить
popular: {
day: 1230 // Поле которое необходимо создать
}
]
function isPopularToDay(request) {
return Promise.all(request.map(async e => {
return Collections.updateOne({ _id: e._id }, { $set: { "popular.day": e.count } }).then()
}))
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question