Saturday, 3 June 2017

Updating a mongoose collection after doing insertMany() in nodejs

I have some JSON dumps with over a thousand records in a JSON array format. These dumps would be created nightly and my job is to keep my db synced with these dumps. Initially for testing I did model.insertMany(json) as I read that it is much more efficient than doing multiple calls to the db. But naturally I cannot use this for my nightly updates since insertMany() fails when a key exists. What should I do in its place which is as efficient?



via Sayak Mukhopadhyay

No comments:

Post a Comment