Answer the question
In order to leave comments, you need to log in
MongoDB how to update duplicates and insert new documents at the same time?
Every hour, an array of objects comes in, in which most of the duplicates and 20 percent of the new values.
The task is that, it is necessary to interpose all this array of documents into a database. Update duplicates, insert new values.
Used this approach:
postsModel.insertMany(result, (err, posts) => {
if (err) {
Logs.info(err);
} else {
Logs.info("Success!");
}
});
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