Skip to content

Commit 003dc7b

Browse files
committed
docs+types(schema): add alternative optimisticConcurrency syntaxes to docs + types
Re: #10591
1 parent 4d93843 commit 003dc7b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/schema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const numberRE = /^\d+$/;
7777
* - [validateBeforeSave](https://mongoosejs.com/docs/guide.html#validateBeforeSave) - bool - defaults to `true`
7878
* - [validateModifiedOnly](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate()) - bool - defaults to `false`
7979
* - [versionKey](https://mongoosejs.com/docs/guide.html#versionKey): string or object - defaults to "__v"
80-
* - [optimisticConcurrency](https://mongoosejs.com/docs/guide.html#optimisticConcurrency): bool - defaults to false. Set to true to enable [optimistic concurrency](https://thecodebarbarian.com/whats-new-in-mongoose-5-10-optimistic-concurrency.html).
80+
* - [optimisticConcurrency](https://mongoosejs.com/docs/guide.html#optimisticConcurrency): bool or string[] or { exclude: string[] } - defaults to false. Set to true to enable [optimistic concurrency](https://thecodebarbarian.com/whats-new-in-mongoose-5-10-optimistic-concurrency.html). Set to string array to enable optimistic concurrency for only certain fields, or `{ exclude: string[] }` to define a list of fields to ignore for optimistic concurrency.
8181
* - [collation](https://mongoosejs.com/docs/guide.html#collation): object - defaults to null (which means use no collation)
8282
* - [timeseries](https://mongoosejs.com/docs/guide.html#timeseries): object - defaults to null (which means this schema's collection won't be a timeseries collection)
8383
* - [selectPopulatedPaths](https://mongoosejs.com/docs/guide.html#selectPopulatedPaths): boolean - defaults to `true`

types/schemaoptions.d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ declare module 'mongoose' {
107107
/**
108108
* Optimistic concurrency is a strategy to ensure the document you're updating didn't change between when you
109109
* loaded it using find() or findOne(), and when you update it using save(). Set to `true` to enable
110-
* optimistic concurrency.
110+
* optimistic concurrency. Set to string array to enable optimistic concurrency for only certain fields,
111+
* or `{ exclude: string[] }` to define a list of fields to ignore for optimistic concurrency.
111112
*/
112-
optimisticConcurrency?: boolean;
113+
optimisticConcurrency?: boolean | string[] | { exclude: string[] };
113114
/**
114115
* If `plugin()` called with tags, Mongoose will only apply plugins to schemas that have
115116
* a matching tag in `pluginTags`

0 commit comments

Comments
 (0)