mongoose 6.9.0 → 6.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/browser.umd.js +1 -1
- package/lib/aggregate.js +41 -42
- package/lib/connection.js +6 -6
- package/lib/cursor/AggregationCursor.js +1 -1
- package/lib/cursor/QueryCursor.js +1 -1
- package/lib/document.js +12 -12
- package/lib/drivers/node-mongodb-native/collection.js +1 -1
- package/lib/error/index.js +21 -10
- package/lib/error/serverSelection.js +1 -1
- package/lib/helpers/document/applyDefaults.js +14 -3
- package/lib/helpers/query/cast$expr.js +1 -1
- package/lib/helpers/query/castUpdate.js +0 -12
- package/lib/index.js +30 -7
- package/lib/model.js +61 -61
- package/lib/query.js +142 -141
- package/lib/schema/SubdocumentPath.js +1 -1
- package/lib/schema/operators/text.js +1 -1
- package/lib/schema/uuid.js +3 -3
- package/lib/schema.js +2 -1
- package/lib/schematype.js +1 -1
- package/lib/types/array/index.js +1 -1
- package/lib/types/array/methods/index.js +4 -3
- package/lib/types/buffer.js +1 -1
- package/lib/virtualtype.js +1 -1
- package/package.json +12 -10
- package/types/aggregate.d.ts +4 -67
- package/types/connection.d.ts +4 -4
- package/types/error.d.ts +5 -0
- package/types/expressions.d.ts +154 -153
- package/types/index.d.ts +3 -3
- package/types/models.d.ts +3 -3
- package/types/mongooseoptions.d.ts +1 -1
- package/types/pipelinestage.d.ts +39 -35
- package/types/query.d.ts +10 -10
- package/types/schematypes.d.ts +1 -1
- package/types/session.d.ts +4 -4
package/types/index.d.ts
CHANGED
|
@@ -493,7 +493,7 @@ declare module 'mongoose' {
|
|
|
493
493
|
export type SortOrder = -1 | 1 | 'asc' | 'ascending' | 'desc' | 'descending';
|
|
494
494
|
|
|
495
495
|
type _UpdateQuery<TSchema> = {
|
|
496
|
-
/** @see https://
|
|
496
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/update-field/ */
|
|
497
497
|
$currentDate?: AnyKeys<TSchema> & AnyObject;
|
|
498
498
|
$inc?: AnyKeys<TSchema> & AnyObject;
|
|
499
499
|
$min?: AnyKeys<TSchema> & AnyObject;
|
|
@@ -504,14 +504,14 @@ declare module 'mongoose' {
|
|
|
504
504
|
$setOnInsert?: AnyKeys<TSchema> & AnyObject;
|
|
505
505
|
$unset?: AnyKeys<TSchema> & AnyObject;
|
|
506
506
|
|
|
507
|
-
/** @see https://
|
|
507
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/update-array/ */
|
|
508
508
|
$addToSet?: AnyKeys<TSchema> & AnyObject;
|
|
509
509
|
$pop?: AnyKeys<TSchema> & AnyObject;
|
|
510
510
|
$pull?: AnyKeys<TSchema> & AnyObject;
|
|
511
511
|
$push?: AnyKeys<TSchema> & AnyObject;
|
|
512
512
|
$pullAll?: AnyKeys<TSchema> & AnyObject;
|
|
513
513
|
|
|
514
|
-
/** @see https://
|
|
514
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/update-bitwise/ */
|
|
515
515
|
// Needs to be `AnyKeys` for now, because anything stricter makes us incompatible
|
|
516
516
|
// with the MongoDB Node driver's `UpdateFilter` interface (see gh-12595, gh-11911)
|
|
517
517
|
// and using the Node driver's `$bit` definition breaks because their `OnlyFieldsOfType`
|
package/types/models.d.ts
CHANGED
|
@@ -140,7 +140,7 @@ declare module 'mongoose' {
|
|
|
140
140
|
>
|
|
141
141
|
> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;
|
|
142
142
|
|
|
143
|
-
aggregate<R = any>(pipeline?: PipelineStage[], options?:
|
|
143
|
+
aggregate<R = any>(pipeline?: PipelineStage[], options?: AggregateOptions, callback?: Callback<R[]>): Aggregate<Array<R>>;
|
|
144
144
|
aggregate<R = any>(pipeline: PipelineStage[], callback?: Callback<R[]>): Aggregate<Array<R>>;
|
|
145
145
|
|
|
146
146
|
/** Base Mongoose instance the model uses. */
|
|
@@ -269,7 +269,7 @@ declare module 'mongoose' {
|
|
|
269
269
|
hydrate(obj: any, projection?: AnyObject, options?: { setters?: boolean }): HydratedDocument<T, TMethodsAndOverrides, TVirtuals>;
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
|
-
* This function is responsible for building [indexes](https://
|
|
272
|
+
* This function is responsible for building [indexes](https://www.mongodb.com/docs/manual/indexes/),
|
|
273
273
|
* unless [`autoIndex`](http://mongoosejs.com/docs/guide.html#autoIndex) is turned off.
|
|
274
274
|
* Mongoose calls this function automatically when a model is created using
|
|
275
275
|
* [`mongoose.model()`](/docs/api/mongoose.html#mongoose_Mongoose-model) or
|
|
@@ -310,7 +310,7 @@ declare module 'mongoose' {
|
|
|
310
310
|
validate(optional: any, callback?: CallbackWithoutResult): Promise<void>;
|
|
311
311
|
validate(optional: any, pathsToValidate: PathsToValidate, callback?: CallbackWithoutResult): Promise<void>;
|
|
312
312
|
|
|
313
|
-
/** Watches the underlying collection for changes using [MongoDB change streams](https://
|
|
313
|
+
/** Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/). */
|
|
314
314
|
watch<ResultType extends mongodb.Document = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType>;
|
|
315
315
|
|
|
316
316
|
/** Adds a `$where` clause to this query */
|
|
@@ -93,7 +93,7 @@ declare module 'mongoose' {
|
|
|
93
93
|
*/
|
|
94
94
|
'timestamps.createdAt.immutable'?: boolean
|
|
95
95
|
|
|
96
|
-
/** If set, attaches [maxTimeMS](https://
|
|
96
|
+
/** If set, attaches [maxTimeMS](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/) to every query */
|
|
97
97
|
maxTimeMS?: number;
|
|
98
98
|
|
|
99
99
|
/**
|
package/types/pipelinestage.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare module 'mongoose' {
|
|
2
2
|
/**
|
|
3
|
-
* [Stages reference](https://
|
|
3
|
+
* [Stages reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/#aggregation-pipeline-stages)
|
|
4
4
|
*/
|
|
5
5
|
export type PipelineStage =
|
|
6
6
|
| PipelineStage.AddFields
|
|
@@ -39,12 +39,12 @@ declare module 'mongoose' {
|
|
|
39
39
|
|
|
40
40
|
export namespace PipelineStage {
|
|
41
41
|
export interface AddFields {
|
|
42
|
-
/** [`$addFields` reference](https://
|
|
42
|
+
/** [`$addFields` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/) */
|
|
43
43
|
$addFields: Record<string, AnyExpression>
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface Bucket {
|
|
47
|
-
/** [`$bucket` reference](https://
|
|
47
|
+
/** [`$bucket` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/) */
|
|
48
48
|
$bucket: {
|
|
49
49
|
groupBy: Expression;
|
|
50
50
|
boundaries: any[];
|
|
@@ -54,7 +54,7 @@ declare module 'mongoose' {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export interface BucketAuto {
|
|
57
|
-
/** [`$bucketAuto` reference](https://
|
|
57
|
+
/** [`$bucketAuto` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/) */
|
|
58
58
|
$bucketAuto: {
|
|
59
59
|
groupBy: Expression | Record<string, Expression>;
|
|
60
60
|
buckets: number;
|
|
@@ -64,7 +64,7 @@ declare module 'mongoose' {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export interface CollStats {
|
|
67
|
-
/** [`$collStats` reference](https://
|
|
67
|
+
/** [`$collStats` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/) */
|
|
68
68
|
$collStats: {
|
|
69
69
|
latencyStats?: { histograms?: boolean };
|
|
70
70
|
storageStats?: { scale?: number };
|
|
@@ -74,12 +74,12 @@ declare module 'mongoose' {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export interface Count {
|
|
77
|
-
/** [`$count` reference](https://
|
|
77
|
+
/** [`$count` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/) */
|
|
78
78
|
$count: string;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export interface Densify{
|
|
82
|
-
/** [`$densify` reference](https://
|
|
82
|
+
/** [`$densify` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/) */
|
|
83
83
|
$densify: {
|
|
84
84
|
field: string,
|
|
85
85
|
partitionByFields?: string[],
|
|
@@ -92,7 +92,7 @@ declare module 'mongoose' {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
export interface Fill {
|
|
95
|
-
/** [`$fill` reference](https://
|
|
95
|
+
/** [`$fill` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/) */
|
|
96
96
|
$fill: {
|
|
97
97
|
partitionBy?: Expression,
|
|
98
98
|
partitionByFields?: string[],
|
|
@@ -102,14 +102,14 @@ declare module 'mongoose' {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export interface Facet {
|
|
105
|
-
/** [`$facet` reference](https://
|
|
105
|
+
/** [`$facet` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/) */
|
|
106
106
|
$facet: Record<string, FacetPipelineStage[]>;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
export type FacetPipelineStage = Exclude<PipelineStage, PipelineStage.CollStats | PipelineStage.Facet | PipelineStage.GeoNear | PipelineStage.IndexStats | PipelineStage.Out | PipelineStage.Merge | PipelineStage.PlanCacheStats>;
|
|
110
110
|
|
|
111
111
|
export interface GeoNear {
|
|
112
|
-
/** [`$geoNear` reference](https://
|
|
112
|
+
/** [`$geoNear` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/) */
|
|
113
113
|
$geoNear: {
|
|
114
114
|
near: { type: 'Point'; coordinates: [number, number] } | [number, number];
|
|
115
115
|
distanceField: string;
|
|
@@ -120,12 +120,16 @@ declare module 'mongoose' {
|
|
|
120
120
|
minDistance?: number;
|
|
121
121
|
query?: AnyObject;
|
|
122
122
|
spherical?: boolean;
|
|
123
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Deprecated. Use only with MondoDB below 4.2 (removed in 4.2)
|
|
125
|
+
* @deprecated
|
|
126
|
+
*/
|
|
127
|
+
num?: number;
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
export interface GraphLookup {
|
|
128
|
-
/** [`$graphLookup` reference](https://
|
|
132
|
+
/** [`$graphLookup` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/) */
|
|
129
133
|
$graphLookup: {
|
|
130
134
|
from: string;
|
|
131
135
|
startWith: any
|
|
@@ -139,27 +143,27 @@ declare module 'mongoose' {
|
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
export interface Group {
|
|
142
|
-
/** [`$group` reference](https://
|
|
146
|
+
/** [`$group` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/group) */
|
|
143
147
|
$group: { _id: any } | { [key: string]: AccumulatorOperator }
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
export interface IndexStats {
|
|
147
|
-
/** [`$indexStats` reference](https://
|
|
151
|
+
/** [`$indexStats` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/) */
|
|
148
152
|
$indexStats: Record<string | number | symbol, never>;
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
export interface Limit {
|
|
152
|
-
/** [`$limit` reference](https://
|
|
156
|
+
/** [`$limit` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/) */
|
|
153
157
|
$limit: number
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
export interface ListSessions {
|
|
157
|
-
/** [`$listSessions` reference](https://
|
|
161
|
+
/** [`$listSessions` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/) */
|
|
158
162
|
$listSessions: { users?: { user: string; db: string }[] } | { allUsers?: true }
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
export interface Lookup {
|
|
162
|
-
/** [`$lookup` reference](https://
|
|
166
|
+
/** [`$lookup` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/) */
|
|
163
167
|
$lookup: {
|
|
164
168
|
from: string
|
|
165
169
|
as: string
|
|
@@ -171,12 +175,12 @@ declare module 'mongoose' {
|
|
|
171
175
|
}
|
|
172
176
|
|
|
173
177
|
export interface Match {
|
|
174
|
-
/** [`$match` reference](https://
|
|
178
|
+
/** [`$match` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/) */
|
|
175
179
|
$match: FilterQuery<any>;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
export interface Merge {
|
|
179
|
-
/** [`$merge` reference](https://
|
|
183
|
+
/** [`$merge` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/) */
|
|
180
184
|
$merge: {
|
|
181
185
|
into: string | { db: string; coll: string }
|
|
182
186
|
on?: string | string[]
|
|
@@ -187,42 +191,42 @@ declare module 'mongoose' {
|
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
export interface Out {
|
|
190
|
-
/** [`$out` reference](https://
|
|
194
|
+
/** [`$out` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/) */
|
|
191
195
|
$out: string | { db: string; coll: string }
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
export interface PlanCacheStats {
|
|
195
|
-
/** [`$planCacheStats` reference](https://
|
|
199
|
+
/** [`$planCacheStats` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/) */
|
|
196
200
|
$planCacheStats: Record<string | number | symbol, never>
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
export interface Project {
|
|
200
|
-
/** [`$project` reference](https://
|
|
204
|
+
/** [`$project` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/) */
|
|
201
205
|
$project: { [field: string]: AnyExpression | Expression | Project['$project'] }
|
|
202
206
|
}
|
|
203
207
|
|
|
204
208
|
export interface Redact {
|
|
205
|
-
/** [`$redact` reference](https://
|
|
209
|
+
/** [`$redact` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/) */
|
|
206
210
|
$redact: Expression;
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
export interface ReplaceRoot {
|
|
210
|
-
/** [`$replaceRoot` reference](https://
|
|
214
|
+
/** [`$replaceRoot` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/) */
|
|
211
215
|
$replaceRoot: { newRoot: AnyExpression }
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
export interface ReplaceWith {
|
|
215
|
-
/** [`$replaceWith` reference](https://
|
|
219
|
+
/** [`$replaceWith` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/) */
|
|
216
220
|
$replaceWith: ObjectExpressionOperator | { [field: string]: Expression } | `$${string}`;
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
export interface Sample {
|
|
220
|
-
/** [`$sample` reference](https://
|
|
224
|
+
/** [`$sample` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/) */
|
|
221
225
|
$sample: { size: number }
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
export interface Search {
|
|
225
|
-
/** [`$search` reference](https://
|
|
229
|
+
/** [`$search` reference](https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/) */
|
|
226
230
|
$search: {
|
|
227
231
|
index?: string;
|
|
228
232
|
highlight?: {
|
|
@@ -236,12 +240,12 @@ declare module 'mongoose' {
|
|
|
236
240
|
}
|
|
237
241
|
|
|
238
242
|
export interface Set {
|
|
239
|
-
/** [`$set` reference](https://
|
|
243
|
+
/** [`$set` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/) */
|
|
240
244
|
$set: Record<string, AnyExpression | any>
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
export interface SetWindowFields {
|
|
244
|
-
/** [`$setWindowFields` reference](https://
|
|
248
|
+
/** [`$setWindowFields` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/) */
|
|
245
249
|
$setWindowFields: {
|
|
246
250
|
partitionBy?: any
|
|
247
251
|
sortBy?: Record<string, 1 | -1>
|
|
@@ -259,34 +263,34 @@ declare module 'mongoose' {
|
|
|
259
263
|
}
|
|
260
264
|
|
|
261
265
|
export interface Skip {
|
|
262
|
-
/** [`$skip` reference](https://
|
|
266
|
+
/** [`$skip` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/) */
|
|
263
267
|
$skip: number
|
|
264
268
|
}
|
|
265
269
|
|
|
266
270
|
export interface Sort {
|
|
267
|
-
/** [`$sort` reference](https://
|
|
271
|
+
/** [`$sort` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/) */
|
|
268
272
|
$sort: Record<string, 1 | -1 | Expression.Meta>
|
|
269
273
|
}
|
|
270
274
|
|
|
271
275
|
export interface SortByCount {
|
|
272
|
-
/** [`$sortByCount` reference](https://
|
|
276
|
+
/** [`$sortByCount` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/) */
|
|
273
277
|
$sortByCount: Expression;
|
|
274
278
|
}
|
|
275
279
|
|
|
276
280
|
export interface UnionWith {
|
|
277
|
-
/** [`$unionWith` reference](https://
|
|
281
|
+
/** [`$unionWith` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/) */
|
|
278
282
|
$unionWith:
|
|
279
283
|
| string
|
|
280
284
|
| { coll: string; pipeline?: Exclude<PipelineStage, PipelineStage.Out | PipelineStage.Merge>[] }
|
|
281
285
|
}
|
|
282
286
|
|
|
283
287
|
export interface Unset {
|
|
284
|
-
/** [`$unset` reference](https://
|
|
288
|
+
/** [`$unset` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/) */
|
|
285
289
|
$unset: string | string[]
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
export interface Unwind {
|
|
289
|
-
/** [`$unwind` reference](https://
|
|
293
|
+
/** [`$unwind` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/) */
|
|
290
294
|
$unwind: string | { path: string; includeArrayIndex?: string; preserveNullAndEmptyArrays?: boolean }
|
|
291
295
|
}
|
|
292
296
|
}
|
package/types/query.d.ts
CHANGED
|
@@ -68,22 +68,22 @@ declare module 'mongoose' {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
type RootQuerySelector<T> = {
|
|
71
|
-
/** @see https://
|
|
71
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/and/#op._S_and */
|
|
72
72
|
$and?: Array<FilterQuery<T>>;
|
|
73
|
-
/** @see https://
|
|
73
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/nor/#op._S_nor */
|
|
74
74
|
$nor?: Array<FilterQuery<T>>;
|
|
75
|
-
/** @see https://
|
|
75
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/or/#op._S_or */
|
|
76
76
|
$or?: Array<FilterQuery<T>>;
|
|
77
|
-
/** @see https://
|
|
77
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/text */
|
|
78
78
|
$text?: {
|
|
79
79
|
$search: string;
|
|
80
80
|
$language?: string;
|
|
81
81
|
$caseSensitive?: boolean;
|
|
82
82
|
$diacriticSensitive?: boolean;
|
|
83
83
|
};
|
|
84
|
-
/** @see https://
|
|
84
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/where/#op._S_where */
|
|
85
85
|
$where?: string | Function;
|
|
86
|
-
/** @see https://
|
|
86
|
+
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/comment/#op._S_comment */
|
|
87
87
|
$comment?: string;
|
|
88
88
|
// we could not find a proper TypeScript generic to support nested queries e.g. 'user.friends.name'
|
|
89
89
|
// this will mark all unrecognized properties as any (including nested queries)
|
|
@@ -292,7 +292,7 @@ declare module 'mongoose' {
|
|
|
292
292
|
exists(val: boolean): this;
|
|
293
293
|
|
|
294
294
|
/**
|
|
295
|
-
* Sets the [`explain` option](https://
|
|
295
|
+
* Sets the [`explain` option](https://www.mongodb.com/docs/manual/reference/method/cursor.explain/),
|
|
296
296
|
* which makes this query return detailed execution stats instead of the actual
|
|
297
297
|
* query result. This method is useful for determining what index your queries
|
|
298
298
|
* use.
|
|
@@ -468,7 +468,7 @@ declare module 'mongoose' {
|
|
|
468
468
|
maxScan(val: number): this;
|
|
469
469
|
|
|
470
470
|
/**
|
|
471
|
-
* Sets the [maxTimeMS](https://
|
|
471
|
+
* Sets the [maxTimeMS](https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/)
|
|
472
472
|
* option. This will tell the MongoDB server to abort if the query or write op
|
|
473
473
|
* has been running for more than `ms` milliseconds.
|
|
474
474
|
*/
|
|
@@ -548,7 +548,7 @@ declare module 'mongoose' {
|
|
|
548
548
|
/**
|
|
549
549
|
* Declare and/or execute this query as a replaceOne() operation. Same as
|
|
550
550
|
* `update()`, except MongoDB will replace the existing document and will
|
|
551
|
-
* not accept any [atomic](https://
|
|
551
|
+
* not accept any [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.)
|
|
552
552
|
*/
|
|
553
553
|
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocType | AnyObject, options?: QueryOptions<DocType> | null, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
554
554
|
|
|
@@ -565,7 +565,7 @@ declare module 'mongoose' {
|
|
|
565
565
|
selectedInclusively(): boolean;
|
|
566
566
|
|
|
567
567
|
/**
|
|
568
|
-
* Sets the [MongoDB session](https://
|
|
568
|
+
* Sets the [MongoDB session](https://www.mongodb.com/docs/manual/reference/server-sessions/)
|
|
569
569
|
* associated with this query. Sessions are how you mark a query as part of a
|
|
570
570
|
* [transaction](/docs/transactions.html).
|
|
571
571
|
*/
|
package/types/schematypes.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare module 'mongoose' {
|
|
|
28
28
|
/**
|
|
29
29
|
* The Mongoose ObjectId [SchemaType](/docs/schematypes.html). Used for
|
|
30
30
|
* declaring paths in your schema that should be
|
|
31
|
-
* [MongoDB ObjectIds](https://
|
|
31
|
+
* [MongoDB ObjectIds](https://www.mongodb.com/docs/manual/reference/method/ObjectId/).
|
|
32
32
|
* Do not use this to create a new ObjectId instance, use `mongoose.Types.ObjectId`
|
|
33
33
|
* instead.
|
|
34
34
|
*/
|
package/types/session.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ declare module 'mongoose' {
|
|
|
5
5
|
type ClientSession = mongodb.ClientSession;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* _Requires MongoDB >= 3.6.0._ Starts a [MongoDB session](https://
|
|
9
|
-
* for benefits like causal consistency, [retryable writes](https://
|
|
8
|
+
* _Requires MongoDB >= 3.6.0._ Starts a [MongoDB session](https://www.mongodb.com/docs/manual/release-notes/3.6/#client-sessions)
|
|
9
|
+
* for benefits like causal consistency, [retryable writes](https://www.mongodb.com/docs/manual/core/retryable-writes/),
|
|
10
10
|
* and [transactions](http://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
|
|
11
11
|
*/
|
|
12
12
|
function startSession(options: ClientSessionOptions | undefined | null, callback: Callback<ClientSession>): void;
|
|
@@ -21,8 +21,8 @@ declare module 'mongoose' {
|
|
|
21
21
|
interface SessionStarter {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Starts a [MongoDB session](https://
|
|
25
|
-
* for benefits like causal consistency, [retryable writes](https://
|
|
24
|
+
* Starts a [MongoDB session](https://www.mongodb.com/docs/manual/release-notes/3.6/#client-sessions)
|
|
25
|
+
* for benefits like causal consistency, [retryable writes](https://www.mongodb.com/docs/manual/core/retryable-writes/),
|
|
26
26
|
* and [transactions](http://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
|
|
27
27
|
*/
|
|
28
28
|
startSession(options: ClientSessionOptions | undefined | null, callback: Callback<ClientSession>): void;
|