Skip to content

Commit

Permalink
fix(schema): throw error if versionKey is not a string
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 1, 2021
1 parent 3401881 commit 8fc256c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/schema.js
Expand Up @@ -412,6 +412,10 @@ Schema.prototype.defaultOptions = function(options) {
options.read = readPref(options.read);
}

if (options.versionKey && typeof options.versionKey !== 'string') {
throw new MongooseError('`versionKey` must be falsy or string, got `' + (typeof options.versionKey) + '`');
}

if (options.optimisticConcurrency && !options.versionKey) {
throw new MongooseError('Must set `versionKey` if using `optimisticConcurrency`');
}
Expand Down

0 comments on commit 8fc256c

Please sign in to comment.