Skip to content

Commit

Permalink
fix(bulkwrite): make bulkWrite can work with timestamps: false
Browse files Browse the repository at this point in the history
fixes #10048
  • Loading branch information
SoftwareSing committed Mar 20, 2021
1 parent 9559c46 commit 0101ab8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/helpers/model/castBulkWrite.js
Expand Up @@ -20,7 +20,7 @@ module.exports = function castBulkWrite(originalModel, op, options) {
const model = decideModelByObject(originalModel, op['insertOne']['document']);

const doc = new model(op['insertOne']['document']);
if (model.schema.options.timestamps != null) {
if (doc.initializeTimestamps) {
doc.initializeTimestamps();
}
if (options.session != null) {
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = function castBulkWrite(originalModel, op, options) {

// set `skipId`, otherwise we get "_id field cannot be changed"
const doc = new model(op['replaceOne']['replacement'], strict, true);
if (model.schema.options.timestamps != null) {
if (doc.initializeTimestamps) {
doc.initializeTimestamps();
}
if (options.session != null) {
Expand Down

0 comments on commit 0101ab8

Please sign in to comment.