I have a schema that has both timestamps and discriminator key options set. Using Model.save()
, everything works fine, but using Model.bulkWrite
neither my discriminator key nor the timestamps get saved/updated.
Is there a way in mongoose to bulk update documents (each with different values) and to maintain the behaviour regarding schema options like in Model.save()
?
My use case is that I have about 500 documents and I have to check for each if the document already exists (if so update parts of it) it and if not insert a complete new record. This works fine with bulkWrite
and an array of updateOne
operations except that the schema options do not work.