Skip to content

Commit 8fc256c

Browse files
committedSep 1, 2021
fix(schema): throw error if versionKey is not a string
1 parent 3401881 commit 8fc256c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎lib/schema.js

+4
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ Schema.prototype.defaultOptions = function(options) {
412412
options.read = readPref(options.read);
413413
}
414414

415+
if (options.versionKey && typeof options.versionKey !== 'string') {
416+
throw new MongooseError('`versionKey` must be falsy or string, got `' + (typeof options.versionKey) + '`');
417+
}
418+
415419
if (options.optimisticConcurrency && !options.versionKey) {
416420
throw new MongooseError('Must set `versionKey` if using `optimisticConcurrency`');
417421
}

0 commit comments

Comments
 (0)
Please sign in to comment.