I have a collection that holds documents that contains three fields: first_name, last_name, and age. I\'m trying to figure out what query in Mongoose I can use to do a bulk
Found the official solution on: https://docs.mongodb.com/manual/reference/method/Bulk.find.upsert/
And Mongoose also supports same chain.
Bulk.find().upsert().update();
Bulk.find().upsert().updateOne();
Bulk.find().upsert().replaceOne();
Tested it works:
BulkWriteResult {
result:
{ ok: 1,
writeErrors: [],
writeConcernErrors: [],
insertedIds: [],
nInserted: 0,
nUpserted: 1,
nMatched: 4186,
nModified: 0,
nRemoved: 0,
upserted: [ [Object] ] } }