mongoose 7.1.0 → 7.1.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/dist/browser.umd.js +1 -1
- package/lib/connection.js +0 -1
- package/lib/document.js +68 -29
- package/lib/drivers/node-mongodb-native/collection.js +7 -1
- package/lib/error/objectParameter.js +1 -1
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +2 -1
- package/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +5 -2
- package/lib/helpers/populate/getModelsMapForPopulate.js +1 -2
- package/lib/helpers/printJestWarning.js +15 -11
- package/lib/helpers/processConnectionOptions.js +4 -3
- package/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
- package/lib/helpers/timestamps/setupTimestamps.js +11 -7
- package/lib/query.js +41 -38
- package/lib/schema/DocumentArrayElement.js +100 -0
- package/lib/schema/SubdocumentPath.js +1 -0
- package/lib/schema/documentarray.js +5 -16
- package/lib/schema/string.js +1 -0
- package/lib/schema.js +27 -0
- package/lib/types/map.js +25 -11
- package/package.json +14 -12
- package/types/document.d.ts +7 -7
- package/types/index.d.ts +10 -3
- package/types/models.d.ts +98 -76
- package/types/query.d.ts +133 -41
package/types/models.d.ts
CHANGED
|
@@ -173,12 +173,12 @@ declare module 'mongoose' {
|
|
|
173
173
|
* if you use `create()`) because with `bulkWrite()` there is only one network
|
|
174
174
|
* round trip to the MongoDB server.
|
|
175
175
|
*/
|
|
176
|
-
bulkWrite(
|
|
177
|
-
writes: Array<mongodb.AnyBulkWriteOperation<
|
|
176
|
+
bulkWrite<DocContents = TRawDocType>(
|
|
177
|
+
writes: Array<mongodb.AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends {} ? DocContents : any)>>,
|
|
178
178
|
options: mongodb.BulkWriteOptions & MongooseBulkWriteOptions & { ordered: false }
|
|
179
179
|
): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[] } }>;
|
|
180
|
-
bulkWrite(
|
|
181
|
-
writes: Array<mongodb.AnyBulkWriteOperation<
|
|
180
|
+
bulkWrite<DocContents = TRawDocType>(
|
|
181
|
+
writes: Array<mongodb.AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends {} ? DocContents : any)>>,
|
|
182
182
|
options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions
|
|
183
183
|
): Promise<mongodb.BulkWriteResult>;
|
|
184
184
|
|
|
@@ -193,17 +193,24 @@ declare module 'mongoose' {
|
|
|
193
193
|
collection: Collection;
|
|
194
194
|
|
|
195
195
|
/** Creates a `count` query: counts the number of documents that match `filter`. */
|
|
196
|
-
count(filter?: FilterQuery<TRawDocType>): QueryWithHelpers<
|
|
196
|
+
count(filter?: FilterQuery<TRawDocType>): QueryWithHelpers<
|
|
197
|
+
number,
|
|
198
|
+
THydratedDocumentType,
|
|
199
|
+
TQueryHelpers,
|
|
200
|
+
TRawDocType,
|
|
201
|
+
'count'
|
|
202
|
+
>;
|
|
197
203
|
|
|
198
204
|
/** Creates a `countDocuments` query: counts the number of documents that match `filter`. */
|
|
199
205
|
countDocuments(
|
|
200
206
|
filter?: FilterQuery<TRawDocType>,
|
|
201
207
|
options?: QueryOptions<TRawDocType>
|
|
202
208
|
): QueryWithHelpers<
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
number,
|
|
210
|
+
THydratedDocumentType,
|
|
211
|
+
TQueryHelpers,
|
|
212
|
+
TRawDocType,
|
|
213
|
+
'countDocuments'
|
|
207
214
|
>;
|
|
208
215
|
|
|
209
216
|
/** Creates a new document or documents */
|
|
@@ -230,18 +237,20 @@ declare module 'mongoose' {
|
|
|
230
237
|
filter?: FilterQuery<TRawDocType>,
|
|
231
238
|
options?: QueryOptions<TRawDocType>
|
|
232
239
|
): QueryWithHelpers<
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
mongodb.DeleteResult,
|
|
241
|
+
THydratedDocumentType,
|
|
242
|
+
TQueryHelpers,
|
|
243
|
+
TRawDocType,
|
|
244
|
+
'deleteMany'
|
|
237
245
|
>;
|
|
238
246
|
deleteMany(
|
|
239
247
|
filter: FilterQuery<TRawDocType>
|
|
240
248
|
): QueryWithHelpers<
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
249
|
+
mongodb.DeleteResult,
|
|
250
|
+
THydratedDocumentType,
|
|
251
|
+
TQueryHelpers,
|
|
252
|
+
TRawDocType,
|
|
253
|
+
'deleteMany'
|
|
245
254
|
>;
|
|
246
255
|
|
|
247
256
|
/**
|
|
@@ -253,18 +262,20 @@ declare module 'mongoose' {
|
|
|
253
262
|
filter?: FilterQuery<TRawDocType>,
|
|
254
263
|
options?: QueryOptions<TRawDocType>
|
|
255
264
|
): QueryWithHelpers<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
265
|
+
mongodb.DeleteResult,
|
|
266
|
+
THydratedDocumentType,
|
|
267
|
+
TQueryHelpers,
|
|
268
|
+
TRawDocType,
|
|
269
|
+
'deleteOne'
|
|
260
270
|
>;
|
|
261
271
|
deleteOne(
|
|
262
272
|
filter: FilterQuery<TRawDocType>
|
|
263
273
|
): QueryWithHelpers<
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
274
|
+
mongodb.DeleteResult,
|
|
275
|
+
THydratedDocumentType,
|
|
276
|
+
TQueryHelpers,
|
|
277
|
+
TRawDocType,
|
|
278
|
+
'deleteOne'
|
|
268
279
|
>;
|
|
269
280
|
|
|
270
281
|
/**
|
|
@@ -282,25 +293,25 @@ declare module 'mongoose' {
|
|
|
282
293
|
id: any,
|
|
283
294
|
projection?: ProjectionType<TRawDocType> | null,
|
|
284
295
|
options?: QueryOptions<TRawDocType> | null
|
|
285
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
296
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne'>;
|
|
286
297
|
findById<ResultDoc = THydratedDocumentType>(
|
|
287
298
|
id: any,
|
|
288
299
|
projection?: ProjectionType<TRawDocType> | null
|
|
289
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
300
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne'>;
|
|
290
301
|
|
|
291
302
|
/** Finds one document. */
|
|
292
303
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
293
304
|
filter?: FilterQuery<TRawDocType>,
|
|
294
305
|
projection?: ProjectionType<TRawDocType> | null,
|
|
295
306
|
options?: QueryOptions<TRawDocType> | null
|
|
296
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
307
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne'>;
|
|
297
308
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
298
309
|
filter?: FilterQuery<TRawDocType>,
|
|
299
310
|
projection?: ProjectionType<TRawDocType> | null
|
|
300
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
311
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne'>;
|
|
301
312
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
302
313
|
filter?: FilterQuery<TRawDocType>
|
|
303
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
314
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne'>;
|
|
304
315
|
|
|
305
316
|
/**
|
|
306
317
|
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
@@ -392,7 +403,7 @@ declare module 'mongoose' {
|
|
|
392
403
|
watch<ResultType extends mongodb.Document = any, ChangeType extends mongodb.ChangeStreamDocument = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType, ChangeType>;
|
|
393
404
|
|
|
394
405
|
/** Adds a `$where` clause to this query */
|
|
395
|
-
$where(argument: string | Function): QueryWithHelpers<Array<THydratedDocumentType>, THydratedDocumentType, TQueryHelpers, TRawDocType>;
|
|
406
|
+
$where(argument: string | Function): QueryWithHelpers<Array<THydratedDocumentType>, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find'>;
|
|
396
407
|
|
|
397
408
|
/** Registered discriminators for this model. */
|
|
398
409
|
discriminators: { [name: string]: Model<any> } | undefined;
|
|
@@ -401,10 +412,22 @@ declare module 'mongoose' {
|
|
|
401
412
|
translateAliases(raw: any): any;
|
|
402
413
|
|
|
403
414
|
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
404
|
-
distinct<ReturnType = any>(field: string, filter?: FilterQuery<TRawDocType>): QueryWithHelpers<
|
|
415
|
+
distinct<ReturnType = any>(field: string, filter?: FilterQuery<TRawDocType>): QueryWithHelpers<
|
|
416
|
+
Array<ReturnType>,
|
|
417
|
+
THydratedDocumentType,
|
|
418
|
+
TQueryHelpers,
|
|
419
|
+
TRawDocType,
|
|
420
|
+
'distinct'
|
|
421
|
+
>;
|
|
405
422
|
|
|
406
423
|
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
407
|
-
estimatedDocumentCount(options?: QueryOptions<TRawDocType>): QueryWithHelpers<
|
|
424
|
+
estimatedDocumentCount(options?: QueryOptions<TRawDocType>): QueryWithHelpers<
|
|
425
|
+
number,
|
|
426
|
+
THydratedDocumentType,
|
|
427
|
+
TQueryHelpers,
|
|
428
|
+
TRawDocType,
|
|
429
|
+
'estimatedDocumentCount'
|
|
430
|
+
>;
|
|
408
431
|
|
|
409
432
|
/**
|
|
410
433
|
* Returns a document with its `_id` if at least one document exists in the database that matches
|
|
@@ -413,16 +436,18 @@ declare module 'mongoose' {
|
|
|
413
436
|
exists(
|
|
414
437
|
filter: FilterQuery<TRawDocType>
|
|
415
438
|
): QueryWithHelpers<
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
439
|
+
{ _id: InferId<TRawDocType> } | null,
|
|
440
|
+
THydratedDocumentType,
|
|
441
|
+
TQueryHelpers,
|
|
442
|
+
TRawDocType,
|
|
443
|
+
'findOne'
|
|
420
444
|
>;
|
|
421
445
|
exists(filter: FilterQuery<TRawDocType>): QueryWithHelpers<
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
446
|
+
{ _id: InferId<TRawDocType> } | null,
|
|
447
|
+
THydratedDocumentType,
|
|
448
|
+
TQueryHelpers,
|
|
449
|
+
TRawDocType,
|
|
450
|
+
'findOne'
|
|
426
451
|
>;
|
|
427
452
|
|
|
428
453
|
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
@@ -430,107 +455,102 @@ declare module 'mongoose' {
|
|
|
430
455
|
filter: FilterQuery<TRawDocType>,
|
|
431
456
|
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
432
457
|
options?: QueryOptions<TRawDocType> | null | undefined
|
|
433
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
458
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find'>;
|
|
434
459
|
find<ResultDoc = THydratedDocumentType>(
|
|
435
460
|
filter: FilterQuery<TRawDocType>,
|
|
436
461
|
projection?: ProjectionType<TRawDocType> | null | undefined
|
|
437
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
462
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find'>;
|
|
438
463
|
find<ResultDoc = THydratedDocumentType>(
|
|
439
464
|
filter: FilterQuery<TRawDocType>
|
|
440
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
465
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find'>;
|
|
441
466
|
find<ResultDoc = THydratedDocumentType>(
|
|
442
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
467
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find'>;
|
|
443
468
|
|
|
444
469
|
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
445
470
|
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
446
471
|
id?: mongodb.ObjectId | any,
|
|
447
472
|
options?: QueryOptions<TRawDocType> | null
|
|
448
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
473
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete'>;
|
|
449
474
|
|
|
450
475
|
/** Creates a `findByIdAndRemove` query, filtering by the given `_id`. */
|
|
451
476
|
findByIdAndRemove<ResultDoc = THydratedDocumentType>(
|
|
452
477
|
id?: mongodb.ObjectId | any,
|
|
453
478
|
options?: QueryOptions<TRawDocType> | null
|
|
454
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
479
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete'>;
|
|
455
480
|
|
|
456
481
|
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
457
482
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
458
483
|
id: mongodb.ObjectId | any,
|
|
459
484
|
update: UpdateQuery<TRawDocType>,
|
|
460
485
|
options: QueryOptions<TRawDocType> & { rawResult: true }
|
|
461
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
486
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>;
|
|
462
487
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
463
488
|
id: mongodb.ObjectId | any,
|
|
464
489
|
update: UpdateQuery<TRawDocType>,
|
|
465
490
|
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
466
|
-
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
491
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>;
|
|
467
492
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
468
493
|
id?: mongodb.ObjectId | any,
|
|
469
494
|
update?: UpdateQuery<TRawDocType>,
|
|
470
495
|
options?: QueryOptions<TRawDocType> | null
|
|
471
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
496
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>;
|
|
472
497
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
473
498
|
id: mongodb.ObjectId | any,
|
|
474
499
|
update: UpdateQuery<TRawDocType>
|
|
475
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
500
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>;
|
|
476
501
|
|
|
477
502
|
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
478
503
|
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
479
504
|
filter?: FilterQuery<TRawDocType>,
|
|
480
505
|
options?: QueryOptions<TRawDocType> | null
|
|
481
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
506
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete'>;
|
|
482
507
|
|
|
483
508
|
/** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */
|
|
484
509
|
findOneAndRemove<ResultDoc = THydratedDocumentType>(
|
|
485
510
|
filter?: FilterQuery<TRawDocType>,
|
|
486
511
|
options?: QueryOptions<TRawDocType> | null
|
|
487
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
512
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndRemove'>;
|
|
488
513
|
|
|
489
514
|
/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
|
|
490
515
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
491
516
|
filter: FilterQuery<TRawDocType>,
|
|
492
517
|
replacement: TRawDocType | AnyObject,
|
|
493
518
|
options: QueryOptions<TRawDocType> & { rawResult: true }
|
|
494
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
519
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace'>;
|
|
495
520
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
496
521
|
filter: FilterQuery<TRawDocType>,
|
|
497
522
|
replacement: TRawDocType | AnyObject,
|
|
498
523
|
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
499
|
-
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
524
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace'>;
|
|
500
525
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
501
526
|
filter?: FilterQuery<TRawDocType>,
|
|
502
527
|
replacement?: TRawDocType | AnyObject,
|
|
503
528
|
options?: QueryOptions<TRawDocType> | null
|
|
504
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
529
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace'>;
|
|
505
530
|
|
|
506
531
|
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
507
532
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
508
533
|
filter: FilterQuery<TRawDocType>,
|
|
509
534
|
update: UpdateQuery<TRawDocType>,
|
|
510
535
|
options: QueryOptions<TRawDocType> & { rawResult: true }
|
|
511
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
536
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>;
|
|
512
537
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
513
538
|
filter: FilterQuery<TRawDocType>,
|
|
514
539
|
update: UpdateQuery<TRawDocType>,
|
|
515
540
|
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
516
|
-
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
541
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>;
|
|
517
542
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
518
543
|
filter?: FilterQuery<TRawDocType>,
|
|
519
544
|
update?: UpdateQuery<TRawDocType>,
|
|
520
545
|
options?: QueryOptions<TRawDocType> | null
|
|
521
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
522
|
-
|
|
523
|
-
geoSearch<ResultDoc = THydratedDocumentType>(
|
|
524
|
-
filter?: FilterQuery<TRawDocType>,
|
|
525
|
-
options?: GeoSearchOptions
|
|
526
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
546
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>;
|
|
527
547
|
|
|
528
548
|
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
529
549
|
replaceOne<ResultDoc = THydratedDocumentType>(
|
|
530
550
|
filter?: FilterQuery<TRawDocType>,
|
|
531
551
|
replacement?: TRawDocType | AnyObject,
|
|
532
552
|
options?: QueryOptions<TRawDocType> | null
|
|
533
|
-
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
553
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'replaceOne'>;
|
|
534
554
|
|
|
535
555
|
/** Schema the model uses. */
|
|
536
556
|
schema: Schema<TRawDocType>;
|
|
@@ -540,31 +560,33 @@ declare module 'mongoose' {
|
|
|
540
560
|
filter?: FilterQuery<TRawDocType>,
|
|
541
561
|
update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
542
562
|
options?: QueryOptions<TRawDocType> | null
|
|
543
|
-
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
563
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateMany'>;
|
|
544
564
|
|
|
545
565
|
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
546
566
|
updateOne<ResultDoc = THydratedDocumentType>(
|
|
547
567
|
filter?: FilterQuery<TRawDocType>,
|
|
548
568
|
update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
549
569
|
options?: QueryOptions<TRawDocType> | null
|
|
550
|
-
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
570
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateOne'>;
|
|
551
571
|
|
|
552
572
|
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
553
573
|
where<ResultDoc = THydratedDocumentType>(
|
|
554
574
|
path: string,
|
|
555
575
|
val?: any
|
|
556
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType>;
|
|
576
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find'>;
|
|
557
577
|
where<ResultDoc = THydratedDocumentType>(obj: object): QueryWithHelpers<
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
578
|
+
Array<ResultDoc>,
|
|
579
|
+
ResultDoc,
|
|
580
|
+
TQueryHelpers,
|
|
581
|
+
TRawDocType,
|
|
582
|
+
'find'
|
|
562
583
|
>;
|
|
563
584
|
where<ResultDoc = THydratedDocumentType>(): QueryWithHelpers<
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
585
|
+
Array<ResultDoc>,
|
|
586
|
+
ResultDoc,
|
|
587
|
+
TQueryHelpers,
|
|
588
|
+
TRawDocType,
|
|
589
|
+
'find'
|
|
568
590
|
>;
|
|
569
591
|
}
|
|
570
592
|
}
|