mongoose 9.10.4 → 9.11.1
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/lib/cast.js +9 -19
- package/lib/cursor/queryCursor.js +4 -1
- package/lib/document.js +344 -219
- package/lib/helpers/discriminator/getDiscriminatorValueFromFilter.js +30 -0
- package/lib/helpers/document/toObjectRecursive.js +49 -0
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +4 -3
- package/lib/helpers/update/castArrayFilters.js +1 -1
- package/lib/query.js +29 -0
- package/lib/schema/array.js +13 -0
- package/lib/schema/documentArray.js +38 -17
- package/lib/schema/documentArrayElement.js +32 -0
- package/package.json +2 -2
- package/tstyche.matrix.json +9 -0
- package/types/connection.d.ts +1 -1
- package/types/document.d.ts +3 -1
- package/types/index.d.ts +2 -2
- package/types/models.d.ts +66 -35
- package/types/query.d.ts +84 -62
package/types/query.d.ts
CHANGED
|
@@ -82,8 +82,9 @@ declare module 'mongoose' {
|
|
|
82
82
|
THelpers = {},
|
|
83
83
|
RawDocType = DocType,
|
|
84
84
|
QueryOp = 'find',
|
|
85
|
-
TDocOverrides = Record<string, never
|
|
86
|
-
|
|
85
|
+
TDocOverrides = Record<string, never>,
|
|
86
|
+
TLeanResultType = RawDocType
|
|
87
|
+
> = Query<ResultType, DocType, THelpers, RawDocType, QueryOp, TDocOverrides, TLeanResultType> & THelpers;
|
|
87
88
|
|
|
88
89
|
interface QueryTimestampsConfig {
|
|
89
90
|
createdAt?: boolean;
|
|
@@ -220,7 +221,7 @@ declare module 'mongoose' {
|
|
|
220
221
|
type QueryOpThatReturnsDocument = 'find' | 'findOne' | 'findOneAndUpdate' | 'findOneAndReplace' | 'findOneAndDelete';
|
|
221
222
|
|
|
222
223
|
type GetLeanResultType<RawDocType, ResultType, QueryOp> = QueryOp extends QueryOpThatReturnsDocument
|
|
223
|
-
? (ResultType extends any[] ?
|
|
224
|
+
? (ResultType extends any[] ? RawDocType[] : RawDocType)
|
|
224
225
|
: ResultType;
|
|
225
226
|
|
|
226
227
|
type MergePopulatePaths<RawDocType, ResultType, QueryOp, Paths, TQueryHelpers, TDocOverrides = Record<string, never>> = QueryOp extends QueryOpThatReturnsDocument
|
|
@@ -235,7 +236,7 @@ declare module 'mongoose' {
|
|
|
235
236
|
: MergeType<ResultType, Paths>
|
|
236
237
|
: MergeType<ResultType, Paths>;
|
|
237
238
|
|
|
238
|
-
class Query<ResultType, DocType, THelpers = {}, RawDocType = unknown, QueryOp = 'find', TDocOverrides = Record<string, never
|
|
239
|
+
class Query<ResultType, DocType, THelpers = {}, RawDocType = unknown, QueryOp = 'find', TDocOverrides = Record<string, never>, TLeanResultType = RawDocType> implements SessionOperation {
|
|
239
240
|
_mongooseOptions: QueryOptions<RawDocType>;
|
|
240
241
|
|
|
241
242
|
/**
|
|
@@ -254,7 +255,8 @@ declare module 'mongoose' {
|
|
|
254
255
|
THelpers,
|
|
255
256
|
RawDocType,
|
|
256
257
|
QueryOp,
|
|
257
|
-
TDocOverrides
|
|
258
|
+
TDocOverrides,
|
|
259
|
+
TLeanResultType
|
|
258
260
|
>;
|
|
259
261
|
|
|
260
262
|
/** Specifies an `$all` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
@@ -316,11 +318,11 @@ declare module 'mongoose' {
|
|
|
316
318
|
countDocuments(
|
|
317
319
|
criteria?: QueryFilter<RawDocType>,
|
|
318
320
|
options?: QueryOptions<RawDocType>
|
|
319
|
-
): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments', TDocOverrides>;
|
|
321
|
+
): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments', TDocOverrides, TLeanResultType>;
|
|
320
322
|
countDocuments(
|
|
321
323
|
criteria?: Query<any, any>,
|
|
322
324
|
options?: QueryOptions<RawDocType>
|
|
323
|
-
): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments', TDocOverrides>;
|
|
325
|
+
): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments', TDocOverrides, TLeanResultType>;
|
|
324
326
|
|
|
325
327
|
/**
|
|
326
328
|
* Returns a wrapper around a [mongodb driver cursor](https://mongodb.github.io/node-mongodb-native/7.0/classes/FindCursor.html).
|
|
@@ -336,18 +338,19 @@ declare module 'mongoose' {
|
|
|
336
338
|
deleteMany(
|
|
337
339
|
filter?: QueryFilter<RawDocType>,
|
|
338
340
|
options?: QueryOptions<RawDocType>
|
|
339
|
-
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides>;
|
|
341
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides, TLeanResultType>;
|
|
340
342
|
deleteMany(
|
|
341
343
|
filter?: Query<any, any>,
|
|
342
344
|
options?: QueryOptions<RawDocType>
|
|
343
|
-
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides>;
|
|
345
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides, TLeanResultType>;
|
|
344
346
|
deleteMany(filter: QueryFilter<RawDocType>): QueryWithHelpers<
|
|
345
347
|
any,
|
|
346
348
|
DocType,
|
|
347
349
|
THelpers,
|
|
348
350
|
RawDocType,
|
|
349
351
|
'deleteMany',
|
|
350
|
-
TDocOverrides
|
|
352
|
+
TDocOverrides,
|
|
353
|
+
TLeanResultType
|
|
351
354
|
>;
|
|
352
355
|
deleteMany(filter: Query<any, any>): QueryWithHelpers<
|
|
353
356
|
any,
|
|
@@ -355,9 +358,10 @@ declare module 'mongoose' {
|
|
|
355
358
|
THelpers,
|
|
356
359
|
RawDocType,
|
|
357
360
|
'deleteMany',
|
|
358
|
-
TDocOverrides
|
|
361
|
+
TDocOverrides,
|
|
362
|
+
TLeanResultType
|
|
359
363
|
>;
|
|
360
|
-
deleteMany(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides>;
|
|
364
|
+
deleteMany(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides, TLeanResultType>;
|
|
361
365
|
|
|
362
366
|
/**
|
|
363
367
|
* Declare and/or execute this query as a `deleteOne()` operation. Works like
|
|
@@ -367,18 +371,19 @@ declare module 'mongoose' {
|
|
|
367
371
|
deleteOne(
|
|
368
372
|
filter?: QueryFilter<RawDocType>,
|
|
369
373
|
options?: QueryOptions<RawDocType>
|
|
370
|
-
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides>;
|
|
374
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides, TLeanResultType>;
|
|
371
375
|
deleteOne(
|
|
372
376
|
filter?: Query<any, any>,
|
|
373
377
|
options?: QueryOptions<RawDocType>
|
|
374
|
-
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides>;
|
|
378
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides, TLeanResultType>;
|
|
375
379
|
deleteOne(filter: QueryFilter<RawDocType>): QueryWithHelpers<
|
|
376
380
|
any,
|
|
377
381
|
DocType,
|
|
378
382
|
THelpers,
|
|
379
383
|
RawDocType,
|
|
380
384
|
'deleteOne',
|
|
381
|
-
TDocOverrides
|
|
385
|
+
TDocOverrides,
|
|
386
|
+
TLeanResultType
|
|
382
387
|
>;
|
|
383
388
|
deleteOne(filter: Query<any, any>): QueryWithHelpers<
|
|
384
389
|
any,
|
|
@@ -386,9 +391,10 @@ declare module 'mongoose' {
|
|
|
386
391
|
THelpers,
|
|
387
392
|
RawDocType,
|
|
388
393
|
'deleteOne',
|
|
389
|
-
TDocOverrides
|
|
394
|
+
TDocOverrides,
|
|
395
|
+
TLeanResultType
|
|
390
396
|
>;
|
|
391
|
-
deleteOne(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides>;
|
|
397
|
+
deleteOne(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides, TLeanResultType>;
|
|
392
398
|
|
|
393
399
|
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
394
400
|
distinct<DocKey extends string, ResultType = unknown>(
|
|
@@ -405,7 +411,8 @@ declare module 'mongoose' {
|
|
|
405
411
|
THelpers,
|
|
406
412
|
RawDocType,
|
|
407
413
|
'distinct',
|
|
408
|
-
TDocOverrides
|
|
414
|
+
TDocOverrides,
|
|
415
|
+
TLeanResultType
|
|
409
416
|
>;
|
|
410
417
|
distinct<DocKey extends string, ResultType = unknown>(
|
|
411
418
|
field: DocKey,
|
|
@@ -421,7 +428,8 @@ declare module 'mongoose' {
|
|
|
421
428
|
THelpers,
|
|
422
429
|
RawDocType,
|
|
423
430
|
'distinct',
|
|
424
|
-
TDocOverrides
|
|
431
|
+
TDocOverrides,
|
|
432
|
+
TLeanResultType
|
|
425
433
|
>;
|
|
426
434
|
|
|
427
435
|
/** Specifies a `$elemMatch` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
@@ -445,7 +453,8 @@ declare module 'mongoose' {
|
|
|
445
453
|
THelpers,
|
|
446
454
|
RawDocType,
|
|
447
455
|
'estimatedDocumentCount',
|
|
448
|
-
TDocOverrides
|
|
456
|
+
TDocOverrides,
|
|
457
|
+
TLeanResultType
|
|
449
458
|
>;
|
|
450
459
|
|
|
451
460
|
/** Specifies a `$exists` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
@@ -465,100 +474,103 @@ declare module 'mongoose' {
|
|
|
465
474
|
filter?: QueryFilter<RawDocType>,
|
|
466
475
|
projection?: ProjectionType<RawDocType> | null,
|
|
467
476
|
options?: QueryOptions<RawDocType> | null
|
|
468
|
-
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TDocOverrides>;
|
|
477
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TDocOverrides, TLeanResultType>;
|
|
469
478
|
find(
|
|
470
479
|
filter?: Query<any, any>,
|
|
471
480
|
projection?: ProjectionType<RawDocType> | null,
|
|
472
481
|
options?: QueryOptions<RawDocType> | null
|
|
473
|
-
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TDocOverrides>;
|
|
482
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TDocOverrides, TLeanResultType>;
|
|
483
|
+
|
|
484
|
+
/** Executes the query as a find and also runs countDocuments, returning [documents, count]. Also requires sort and limit to be set. */
|
|
485
|
+
findAndCount(): Promise<[ResultType, number]>;
|
|
474
486
|
|
|
475
487
|
/** Declares the query a findOne operation. When executed, returns the first found document. */
|
|
476
488
|
findOne(
|
|
477
489
|
filter?: QueryFilter<RawDocType>,
|
|
478
490
|
projection?: ProjectionType<RawDocType> | null,
|
|
479
491
|
options?: QueryOptions<RawDocType> | null
|
|
480
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides>;
|
|
492
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides, TLeanResultType>;
|
|
481
493
|
findOne(
|
|
482
494
|
filter?: Query<any, any>,
|
|
483
495
|
projection?: ProjectionType<RawDocType> | null,
|
|
484
496
|
options?: QueryOptions<RawDocType> | null
|
|
485
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides>;
|
|
497
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides, TLeanResultType>;
|
|
486
498
|
|
|
487
499
|
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
488
500
|
findOneAndDelete(
|
|
489
501
|
filter?: QueryFilter<RawDocType>,
|
|
490
502
|
options?: QueryOptions<RawDocType> | null
|
|
491
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete'>;
|
|
503
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides, TLeanResultType>;
|
|
492
504
|
findOneAndDelete(
|
|
493
505
|
filter?: Query<any, any>,
|
|
494
506
|
options?: QueryOptions<RawDocType> | null
|
|
495
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete'>;
|
|
507
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides, TLeanResultType>;
|
|
496
508
|
|
|
497
509
|
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
498
510
|
findOneAndUpdate(
|
|
499
511
|
filter: QueryFilter<RawDocType>,
|
|
500
512
|
update: UpdateQuery<RawDocType>,
|
|
501
513
|
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
502
|
-
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
514
|
+
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
503
515
|
findOneAndUpdate(
|
|
504
516
|
filter: Query<any, any>,
|
|
505
517
|
update: UpdateQuery<RawDocType>,
|
|
506
518
|
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
507
|
-
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
519
|
+
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
508
520
|
findOneAndUpdate(
|
|
509
521
|
filter: QueryFilter<RawDocType>,
|
|
510
522
|
update: UpdateQuery<RawDocType>,
|
|
511
523
|
options: QueryOptions<RawDocType> & { upsert: true } & ReturnsNewDoc
|
|
512
|
-
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
524
|
+
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
513
525
|
findOneAndUpdate(
|
|
514
526
|
filter: Query<any, any>,
|
|
515
527
|
update: UpdateQuery<RawDocType>,
|
|
516
528
|
options: QueryOptions<RawDocType> & { upsert: true } & ReturnsNewDoc
|
|
517
|
-
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
529
|
+
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
518
530
|
findOneAndUpdate(
|
|
519
531
|
filter?: QueryFilter<RawDocType>,
|
|
520
532
|
update?: UpdateQuery<RawDocType>,
|
|
521
533
|
options?: QueryOptions<RawDocType> | null
|
|
522
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
534
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
523
535
|
findOneAndUpdate(
|
|
524
536
|
filter?: Query<any, any>,
|
|
525
537
|
update?: UpdateQuery<RawDocType>,
|
|
526
538
|
options?: QueryOptions<RawDocType> | null
|
|
527
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
539
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
528
540
|
|
|
529
541
|
/** Declares the query a findById operation. When executed, returns the document with the given `_id`. */
|
|
530
542
|
findById(
|
|
531
543
|
id: mongodb.ObjectId | any,
|
|
532
544
|
projection?: ProjectionType<RawDocType> | null,
|
|
533
545
|
options?: QueryOptions<RawDocType> | null
|
|
534
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides>;
|
|
546
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides, TLeanResultType>;
|
|
535
547
|
|
|
536
548
|
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
537
549
|
findByIdAndDelete(
|
|
538
550
|
id: mongodb.ObjectId | any,
|
|
539
551
|
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
540
|
-
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides>;
|
|
552
|
+
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides, TLeanResultType>;
|
|
541
553
|
findByIdAndDelete(
|
|
542
554
|
id?: mongodb.ObjectId | any,
|
|
543
555
|
options?: QueryOptions<RawDocType> | null
|
|
544
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides>;
|
|
556
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides, TLeanResultType>;
|
|
545
557
|
|
|
546
558
|
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
547
559
|
findByIdAndUpdate(
|
|
548
560
|
id: mongodb.ObjectId | any,
|
|
549
561
|
update: UpdateQuery<RawDocType>,
|
|
550
562
|
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
551
|
-
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
563
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
552
564
|
findByIdAndUpdate(
|
|
553
565
|
id: mongodb.ObjectId | any,
|
|
554
566
|
update: UpdateQuery<RawDocType>,
|
|
555
567
|
options: QueryOptions<RawDocType> & { upsert: true } & ReturnsNewDoc
|
|
556
|
-
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
568
|
+
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
557
569
|
findByIdAndUpdate(
|
|
558
570
|
id?: mongodb.ObjectId | any,
|
|
559
571
|
update?: UpdateQuery<RawDocType>,
|
|
560
572
|
options?: QueryOptions<RawDocType> | null
|
|
561
|
-
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
573
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides, TLeanResultType>;
|
|
562
574
|
|
|
563
575
|
/** Specifies a `$geometry` condition */
|
|
564
576
|
geometry(object: { type: string, coordinates: any[] }): this;
|
|
@@ -609,25 +621,27 @@ declare module 'mongoose' {
|
|
|
609
621
|
/** Sets the lean option. */
|
|
610
622
|
lean(): QueryWithHelpers<
|
|
611
623
|
ResultType extends null
|
|
612
|
-
? GetLeanResultType<
|
|
613
|
-
: GetLeanResultType<
|
|
624
|
+
? GetLeanResultType<TLeanResultType, ResultType, QueryOp> | null
|
|
625
|
+
: GetLeanResultType<TLeanResultType, ResultType, QueryOp>,
|
|
614
626
|
DocType,
|
|
615
627
|
THelpers,
|
|
616
628
|
RawDocType,
|
|
617
629
|
QueryOp,
|
|
618
|
-
TDocOverrides
|
|
630
|
+
TDocOverrides,
|
|
631
|
+
TLeanResultType
|
|
619
632
|
>;
|
|
620
633
|
lean(
|
|
621
634
|
val: true | LeanOptions
|
|
622
635
|
): QueryWithHelpers<
|
|
623
636
|
ResultType extends null
|
|
624
|
-
? GetLeanResultType<
|
|
625
|
-
: GetLeanResultType<
|
|
637
|
+
? GetLeanResultType<TLeanResultType, ResultType, QueryOp> | null
|
|
638
|
+
: GetLeanResultType<TLeanResultType, ResultType, QueryOp>,
|
|
626
639
|
DocType,
|
|
627
640
|
THelpers,
|
|
628
641
|
RawDocType,
|
|
629
642
|
QueryOp,
|
|
630
|
-
TDocOverrides
|
|
643
|
+
TDocOverrides,
|
|
644
|
+
TLeanResultType
|
|
631
645
|
>;
|
|
632
646
|
lean(
|
|
633
647
|
val: false
|
|
@@ -641,9 +655,10 @@ declare module 'mongoose' {
|
|
|
641
655
|
THelpers,
|
|
642
656
|
RawDocType,
|
|
643
657
|
QueryOp,
|
|
644
|
-
TDocOverrides
|
|
658
|
+
TDocOverrides,
|
|
659
|
+
TLeanResultType
|
|
645
660
|
>;
|
|
646
|
-
lean<LeanResultType =
|
|
661
|
+
lean<LeanResultType = TLeanResultType>(): QueryWithHelpers<
|
|
647
662
|
ResultType extends null
|
|
648
663
|
? LeanResultType | null
|
|
649
664
|
: LeanResultType,
|
|
@@ -651,9 +666,10 @@ declare module 'mongoose' {
|
|
|
651
666
|
THelpers,
|
|
652
667
|
RawDocType,
|
|
653
668
|
QueryOp,
|
|
654
|
-
TDocOverrides
|
|
669
|
+
TDocOverrides,
|
|
670
|
+
LeanResultType
|
|
655
671
|
>;
|
|
656
|
-
lean<LeanResultType =
|
|
672
|
+
lean<LeanResultType = TLeanResultType>(
|
|
657
673
|
val: boolean | LeanOptions
|
|
658
674
|
): QueryWithHelpers<
|
|
659
675
|
ResultType extends null
|
|
@@ -663,7 +679,8 @@ declare module 'mongoose' {
|
|
|
663
679
|
THelpers,
|
|
664
680
|
RawDocType,
|
|
665
681
|
QueryOp,
|
|
666
|
-
TDocOverrides
|
|
682
|
+
TDocOverrides,
|
|
683
|
+
LeanResultType
|
|
667
684
|
>;
|
|
668
685
|
|
|
669
686
|
/** Specifies the maximum number of documents the query will return. */
|
|
@@ -681,7 +698,7 @@ declare module 'mongoose' {
|
|
|
681
698
|
* Runs a function `fn` and treats the return value of `fn` as the new value
|
|
682
699
|
* for the query to resolve to.
|
|
683
700
|
*/
|
|
684
|
-
transform<MappedType>(fn: (doc: ResultType) => MappedType): QueryWithHelpers<MappedType, DocType, THelpers, RawDocType, QueryOp, TDocOverrides>;
|
|
701
|
+
transform<MappedType>(fn: (doc: ResultType) => MappedType): QueryWithHelpers<MappedType, DocType, THelpers, RawDocType, QueryOp, TDocOverrides, TLeanResultType>;
|
|
685
702
|
|
|
686
703
|
/** Specifies an `$maxDistance` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
687
704
|
maxDistance(path: string, val: number): this;
|
|
@@ -734,7 +751,7 @@ declare module 'mongoose' {
|
|
|
734
751
|
* This is handy for integrating with async/await, because `orFail()` saves you
|
|
735
752
|
* an extra `if` statement to check if no document was found.
|
|
736
753
|
*/
|
|
737
|
-
orFail(err?: NativeError | (() => NativeError)): QueryWithHelpers<NonNullable<ResultType>, DocType, THelpers, RawDocType, QueryOp, TDocOverrides>;
|
|
754
|
+
orFail(err?: NativeError | (() => NativeError)): QueryWithHelpers<NonNullable<ResultType>, DocType, THelpers, RawDocType, QueryOp, TDocOverrides, TLeanResultType>;
|
|
738
755
|
|
|
739
756
|
/** Specifies a `$polygon` condition */
|
|
740
757
|
polygon(path: string, ...coordinatePairs: number[][]): this;
|
|
@@ -752,7 +769,8 @@ declare module 'mongoose' {
|
|
|
752
769
|
THelpers,
|
|
753
770
|
RawDocType,
|
|
754
771
|
QueryOp,
|
|
755
|
-
TDocOverrides
|
|
772
|
+
TDocOverrides,
|
|
773
|
+
TLeanResultType
|
|
756
774
|
>;
|
|
757
775
|
populate(
|
|
758
776
|
options: PopulateOptions | (PopulateOptions | string)[]
|
|
@@ -762,7 +780,8 @@ declare module 'mongoose' {
|
|
|
762
780
|
THelpers,
|
|
763
781
|
RawDocType,
|
|
764
782
|
QueryOp,
|
|
765
|
-
TDocOverrides
|
|
783
|
+
TDocOverrides,
|
|
784
|
+
TLeanResultType
|
|
766
785
|
>;
|
|
767
786
|
populate<Paths>(
|
|
768
787
|
path: string | string[],
|
|
@@ -775,7 +794,8 @@ declare module 'mongoose' {
|
|
|
775
794
|
THelpers,
|
|
776
795
|
UnpackedIntersection<RawDocType, Paths>,
|
|
777
796
|
QueryOp,
|
|
778
|
-
TDocOverrides
|
|
797
|
+
TDocOverrides,
|
|
798
|
+
UnpackedIntersection<TLeanResultType, Paths>
|
|
779
799
|
>;
|
|
780
800
|
populate<Paths>(
|
|
781
801
|
options: PopulateOptions | (PopulateOptions | string)[]
|
|
@@ -785,7 +805,8 @@ declare module 'mongoose' {
|
|
|
785
805
|
THelpers,
|
|
786
806
|
UnpackedIntersection<RawDocType, Paths>,
|
|
787
807
|
QueryOp,
|
|
788
|
-
TDocOverrides
|
|
808
|
+
TDocOverrides,
|
|
809
|
+
UnpackedIntersection<TLeanResultType, Paths>
|
|
789
810
|
>;
|
|
790
811
|
|
|
791
812
|
/** Add pre middleware to this query instance. Doesn't affect other queries. */
|
|
@@ -818,12 +839,12 @@ declare module 'mongoose' {
|
|
|
818
839
|
filter?: QueryFilter<RawDocType>,
|
|
819
840
|
replacement?: DocType | AnyObject,
|
|
820
841
|
options?: QueryOptions<RawDocType> | null
|
|
821
|
-
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne', TDocOverrides>;
|
|
842
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne', TDocOverrides, TLeanResultType>;
|
|
822
843
|
replaceOne(
|
|
823
844
|
filter?: Query<any, any>,
|
|
824
845
|
replacement?: DocType | AnyObject,
|
|
825
846
|
options?: QueryOptions<RawDocType> | null
|
|
826
|
-
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne', TDocOverrides>;
|
|
847
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne', TDocOverrides, TLeanResultType>;
|
|
827
848
|
|
|
828
849
|
/**
|
|
829
850
|
* Sets this query's `sanitizeProjection` option. With `sanitizeProjection()`, you can pass potentially untrusted user data to `.select()`.
|
|
@@ -861,7 +882,8 @@ declare module 'mongoose' {
|
|
|
861
882
|
RawDocTypeOverride
|
|
862
883
|
>,
|
|
863
884
|
QueryOp,
|
|
864
|
-
TDocOverrides
|
|
885
|
+
TDocOverrides,
|
|
886
|
+
IfEquals<RawDocTypeOverride, {}, TLeanResultType, RawDocTypeOverride>
|
|
865
887
|
>;
|
|
866
888
|
|
|
867
889
|
/** Determines if field selection has been made. */
|
|
@@ -936,12 +958,12 @@ declare module 'mongoose' {
|
|
|
936
958
|
filter: QueryFilter<RawDocType>,
|
|
937
959
|
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
938
960
|
options?: QueryOptions<RawDocType> | null
|
|
939
|
-
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany', TDocOverrides>;
|
|
961
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany', TDocOverrides, TLeanResultType>;
|
|
940
962
|
updateMany(
|
|
941
963
|
filter: Query<any, any>,
|
|
942
964
|
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
943
965
|
options?: QueryOptions<RawDocType> | null
|
|
944
|
-
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany', TDocOverrides>;
|
|
966
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany', TDocOverrides, TLeanResultType>;
|
|
945
967
|
|
|
946
968
|
/**
|
|
947
969
|
* Declare and/or execute this query as an updateOne() operation. Same as
|
|
@@ -951,12 +973,12 @@ declare module 'mongoose' {
|
|
|
951
973
|
filter: QueryFilter<RawDocType>,
|
|
952
974
|
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
953
975
|
options?: QueryOptions<RawDocType> | null
|
|
954
|
-
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne', TDocOverrides>;
|
|
976
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne', TDocOverrides, TLeanResultType>;
|
|
955
977
|
updateOne(
|
|
956
978
|
filter: Query<any, any>,
|
|
957
979
|
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
958
980
|
options?: QueryOptions<RawDocType> | null
|
|
959
|
-
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne', TDocOverrides>;
|
|
981
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne', TDocOverrides, TLeanResultType>;
|
|
960
982
|
|
|
961
983
|
/**
|
|
962
984
|
* Sets the specified number of `mongod` servers, or tag set of `mongod` servers,
|