Answer the question
In order to leave comments, you need to log in
Ways to update a lot of Mongodb objects?
It is necessary to periodically update the database of 20k objects. I want to give 2 solutions, if you know better solutions, write.
1. We turn to the database and take all the objects, then we do everything we need with them, delete all the old objects from the table and insert new ones
Model.find({}, (err, data) => {
//work with data
Model.deleteMany({}, () => {
Model.insertMany(data)
})
})
Answer the question
In order to leave comments, you need to log in
1. why do you need to delete everything first, then create it? try https://docs.mongodb.com/manual/reference/method/d... compare the speed, whichever is faster and use it.
2. in general, some kind of perversion, so it's easier for you to just json - keep the file in the cloud - it will be read / updated faster.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question