I'm upserting Documents
into a Collection
using mongoimport
. I'm using shelljs
to just run the actual mongoimport
command the same way it'd be run through a CLI.
E.g.
mongoimport docs.json -d DB -c Collection --jsonArray --upsertFields=foo,bar
This just outputs the # of Documents
updated - but doesn't give any further details on what exactly was changed.
However, I need to be able to see which documents were actually updated/inserted and then do something with these results. I would've thought there'd be some way to get the resulting Object
IDs of these documents
(perhaps through some -v verbose
flag) - but upon doing research, it surprisingly seems that there is no way.
Does anybody know how to get the updated Documents
using mongoimport
? If it's truly not possible, is there some way to do this using Mongoose
? Also, is there any way to check a diff of what exactly was updated on a Document
i.e. what fields changed on an upsert? Thanks!