Skip to content

Commit

Permalink
chore: address CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 22, 2021
1 parent 003e477 commit 3759f34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 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 (doc.initializeTimestamps) {
if (model.schema.options.timestamps) {
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 (doc.initializeTimestamps) {
if (model.schema.options.timestamps) {
doc.initializeTimestamps();
}
if (options.session != null) {
Expand Down Expand Up @@ -221,4 +221,4 @@ function decideModelByObject(model, object) {
model = getDiscriminatorByValue(model, object[discriminatorKey]) || model;
}
return model;
}
}

0 comments on commit 3759f34

Please sign in to comment.