diff --git a/lib/mongoose-field-encryption.js b/lib/mongoose-field-encryption.js index f6b1847..d3783f1 100644 --- a/lib/mongoose-field-encryption.js +++ b/lib/mongoose-field-encryption.js @@ -194,6 +194,7 @@ const fieldEncryption = function (schema, options) { function updateHook(_next) { const next = getCompatitibleNextFunc(_next); + if (this._update === undefined) next(); for (const field of fieldsToEncrypt) { const encryptedFieldName = encryptedFieldNamePrefix + field; this._update.$set = this._update.$set || {};