mongoose 8.9.2 → 8.9.3
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/cursor/queryCursor.js +3 -9
- package/lib/document.js +5 -2
- package/lib/model.js +19 -1
- package/lib/schema.js +1 -1
- package/lib/utils.js +3 -0
- package/package.json +1 -1
- package/types/index.d.ts +61 -49
- package/types/indexes.d.ts +3 -0
- package/types/models.d.ts +47 -47
- package/types/query.d.ts +49 -49
|
@@ -557,17 +557,11 @@ function _onNext(error, doc) {
|
|
|
557
557
|
|
|
558
558
|
if (this.ctx._batchDocs.length < this.ctx.options._populateBatchSize) {
|
|
559
559
|
// If both `batchSize` and `_populateBatchSize` are huge, calling `next()` repeatedly may
|
|
560
|
-
// cause a stack overflow. So make sure we clear the stack
|
|
561
|
-
|
|
562
|
-
return immediate(() => this.ctx.cursor.next().then(
|
|
563
|
-
res => { _onNext.call(this, null, res); },
|
|
564
|
-
err => { _onNext.call(this, err); }
|
|
565
|
-
));
|
|
566
|
-
}
|
|
567
|
-
this.ctx.cursor.next().then(
|
|
560
|
+
// cause a stack overflow. So make sure we clear the stack.
|
|
561
|
+
immediate(() => this.ctx.cursor.next().then(
|
|
568
562
|
res => { _onNext.call(this, null, res); },
|
|
569
563
|
err => { _onNext.call(this, err); }
|
|
570
|
-
);
|
|
564
|
+
));
|
|
571
565
|
} else {
|
|
572
566
|
_populateBatch.call(this);
|
|
573
567
|
}
|
package/lib/document.js
CHANGED
|
@@ -3703,8 +3703,10 @@ Document.prototype.$getAllSubdocs = function(options) {
|
|
|
3703
3703
|
const subDocs = [];
|
|
3704
3704
|
function getSubdocs(doc) {
|
|
3705
3705
|
const newSubdocs = [];
|
|
3706
|
-
|
|
3707
|
-
|
|
3706
|
+
|
|
3707
|
+
for (const { model } of doc.$__schema.childSchemas) {
|
|
3708
|
+
// Avoid using `childSchemas.path` to avoid compatibility versions with pre-8.8 versions of Mongoose
|
|
3709
|
+
const val = doc.$__getValue(model.path);
|
|
3708
3710
|
if (val == null) {
|
|
3709
3711
|
continue;
|
|
3710
3712
|
}
|
|
@@ -3726,6 +3728,7 @@ Document.prototype.$getAllSubdocs = function(options) {
|
|
|
3726
3728
|
}
|
|
3727
3729
|
}
|
|
3728
3730
|
}
|
|
3731
|
+
|
|
3729
3732
|
for (const subdoc of newSubdocs) {
|
|
3730
3733
|
getSubdocs(subdoc);
|
|
3731
3734
|
}
|
package/lib/model.js
CHANGED
|
@@ -69,6 +69,7 @@ const util = require('util');
|
|
|
69
69
|
const utils = require('./utils');
|
|
70
70
|
const minimize = require('./helpers/minimize');
|
|
71
71
|
const MongooseBulkSaveIncompleteError = require('./error/bulkSaveIncompleteError');
|
|
72
|
+
const ObjectExpectedError = require('./error/objectExpected');
|
|
72
73
|
|
|
73
74
|
const modelCollectionSymbol = Symbol('mongoose#Model#collection');
|
|
74
75
|
const modelDbSymbol = Symbol('mongoose#Model#db');
|
|
@@ -387,7 +388,11 @@ Model.prototype.$__handleSave = function(options, callback) {
|
|
|
387
388
|
|
|
388
389
|
this[modelCollectionSymbol].updateOne(where, update, saveOptions).then(
|
|
389
390
|
ret => {
|
|
390
|
-
ret
|
|
391
|
+
if (ret == null) {
|
|
392
|
+
ret = { $where: where };
|
|
393
|
+
} else {
|
|
394
|
+
ret.$where = where;
|
|
395
|
+
}
|
|
391
396
|
callback(null, ret);
|
|
392
397
|
},
|
|
393
398
|
err => {
|
|
@@ -3687,6 +3692,19 @@ Model.castObject = function castObject(obj, options) {
|
|
|
3687
3692
|
}
|
|
3688
3693
|
|
|
3689
3694
|
if (schemaType.$isMongooseDocumentArray) {
|
|
3695
|
+
const castNonArraysOption = schemaType.options?.castNonArrays ?? schemaType.constructor.options.castNonArrays;
|
|
3696
|
+
if (!Array.isArray(val)) {
|
|
3697
|
+
if (!castNonArraysOption) {
|
|
3698
|
+
if (!options.ignoreCastErrors) {
|
|
3699
|
+
error = error || new ValidationError();
|
|
3700
|
+
error.addError(path, new ObjectExpectedError(path, val));
|
|
3701
|
+
}
|
|
3702
|
+
} else {
|
|
3703
|
+
cur[pieces[pieces.length - 1]] = [
|
|
3704
|
+
Model.castObject.call(schemaType.caster, val)
|
|
3705
|
+
];
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3690
3708
|
continue;
|
|
3691
3709
|
}
|
|
3692
3710
|
if (schemaType.$isSingleNested || schemaType.$isMongooseDocumentArrayElement) {
|
package/lib/schema.js
CHANGED
|
@@ -2148,7 +2148,7 @@ Schema.prototype.index = function(fields, options) {
|
|
|
2148
2148
|
|
|
2149
2149
|
for (const existingIndex of this.indexes()) {
|
|
2150
2150
|
if (options.name == null && existingIndex[1].name == null && isIndexSpecEqual(existingIndex[0], fields)) {
|
|
2151
|
-
|
|
2151
|
+
utils.warn(`Duplicate schema index on ${JSON.stringify(fields)} found. This is often due to declaring an index using both "index: true" and "schema.index()". Please remove the duplicate index definition.`);
|
|
2152
2152
|
}
|
|
2153
2153
|
}
|
|
2154
2154
|
|
package/lib/utils.js
CHANGED
|
@@ -631,6 +631,9 @@ exports.getValue = function(path, obj, map) {
|
|
|
631
631
|
const mapGetterOptions = Object.freeze({ getters: false });
|
|
632
632
|
|
|
633
633
|
function getValueLookup(obj, part) {
|
|
634
|
+
if (part === '$*' && obj instanceof Map) {
|
|
635
|
+
return obj;
|
|
636
|
+
}
|
|
634
637
|
let _from = obj?._doc || obj;
|
|
635
638
|
if (_from != null && _from.isMongooseArrayProxy) {
|
|
636
639
|
_from = _from.__array;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -491,7 +491,7 @@ declare module 'mongoose' {
|
|
|
491
491
|
remove(paths: string | Array<string>): this;
|
|
492
492
|
|
|
493
493
|
/** Removes index by name or index spec */
|
|
494
|
-
|
|
494
|
+
removeIndex(index: string | AnyObject): this;
|
|
495
495
|
|
|
496
496
|
/** Returns an Array of path strings that are required by this schema. */
|
|
497
497
|
requiredPaths(invalidate?: boolean): string[];
|
|
@@ -715,16 +715,18 @@ declare module 'mongoose' {
|
|
|
715
715
|
*/
|
|
716
716
|
export type BufferToBinary<T> = T extends Buffer
|
|
717
717
|
? mongodb.Binary
|
|
718
|
-
: T extends
|
|
718
|
+
: T extends Document
|
|
719
719
|
? T
|
|
720
|
-
: T extends
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
: T[K] extends
|
|
724
|
-
?
|
|
725
|
-
: T[K] extends Types.
|
|
726
|
-
?
|
|
727
|
-
:
|
|
720
|
+
: T extends TreatAsPrimitives
|
|
721
|
+
? T
|
|
722
|
+
: T extends Record<string, any> ? {
|
|
723
|
+
[K in keyof T]: T[K] extends Buffer
|
|
724
|
+
? mongodb.Binary
|
|
725
|
+
: T[K] extends Types.DocumentArray<infer ItemType>
|
|
726
|
+
? Types.DocumentArray<BufferToBinary<ItemType>>
|
|
727
|
+
: T[K] extends Types.Subdocument<unknown, unknown, infer SubdocType>
|
|
728
|
+
? HydratedSingleSubdocument<BufferToBinary<SubdocType>>
|
|
729
|
+
: BufferToBinary<T[K]>;
|
|
728
730
|
} : T;
|
|
729
731
|
|
|
730
732
|
/**
|
|
@@ -732,64 +734,74 @@ declare module 'mongoose' {
|
|
|
732
734
|
*/
|
|
733
735
|
export type BufferToJSON<T> = T extends Buffer
|
|
734
736
|
? { type: 'buffer', data: number[] }
|
|
735
|
-
: T extends
|
|
737
|
+
: T extends Document
|
|
736
738
|
? T
|
|
737
|
-
: T extends
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
: T[K] extends
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
?
|
|
744
|
-
:
|
|
745
|
-
|
|
739
|
+
: T extends TreatAsPrimitives
|
|
740
|
+
? T
|
|
741
|
+
: T extends Record<string, any> ? {
|
|
742
|
+
[K in keyof T]: T[K] extends Buffer
|
|
743
|
+
? { type: 'buffer', data: number[] }
|
|
744
|
+
: T[K] extends Types.DocumentArray<infer ItemType>
|
|
745
|
+
? Types.DocumentArray<BufferToBinary<ItemType>>
|
|
746
|
+
: T[K] extends Types.Subdocument<unknown, unknown, infer SubdocType>
|
|
747
|
+
? HydratedSingleSubdocument<SubdocType>
|
|
748
|
+
: BufferToBinary<T[K]>;
|
|
749
|
+
} : T;
|
|
746
750
|
|
|
747
751
|
/**
|
|
748
752
|
* Converts any ObjectId properties into strings for JSON serialization
|
|
749
753
|
*/
|
|
750
754
|
export type ObjectIdToString<T> = T extends mongodb.ObjectId
|
|
751
755
|
? string
|
|
752
|
-
: T extends
|
|
756
|
+
: T extends Document
|
|
753
757
|
? T
|
|
754
|
-
: T extends
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
: T[K] extends
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
?
|
|
761
|
-
:
|
|
762
|
-
|
|
758
|
+
: T extends TreatAsPrimitives
|
|
759
|
+
? T
|
|
760
|
+
: T extends Record<string, any> ? {
|
|
761
|
+
[K in keyof T]: T[K] extends mongodb.ObjectId
|
|
762
|
+
? string
|
|
763
|
+
: T[K] extends Types.DocumentArray<infer ItemType>
|
|
764
|
+
? Types.DocumentArray<ObjectIdToString<ItemType>>
|
|
765
|
+
: T[K] extends Types.Subdocument<unknown, unknown, infer SubdocType>
|
|
766
|
+
? HydratedSingleSubdocument<ObjectIdToString<SubdocType>>
|
|
767
|
+
: ObjectIdToString<T[K]>;
|
|
768
|
+
} : T;
|
|
763
769
|
|
|
764
770
|
/**
|
|
765
771
|
* Converts any Date properties into strings for JSON serialization
|
|
766
772
|
*/
|
|
767
773
|
export type DateToString<T> = T extends NativeDate
|
|
768
774
|
? string
|
|
769
|
-
: T extends
|
|
775
|
+
: T extends Document
|
|
770
776
|
? T
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
: T[K] extends
|
|
775
|
-
? string
|
|
776
|
-
: T[K] extends
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
?
|
|
780
|
-
:
|
|
781
|
-
|
|
777
|
+
: T extends TreatAsPrimitives
|
|
778
|
+
? T
|
|
779
|
+
: T extends Record<string, any> ? {
|
|
780
|
+
[K in keyof T]: T[K] extends NativeDate
|
|
781
|
+
? string
|
|
782
|
+
: T[K] extends (NativeDate | null | undefined)
|
|
783
|
+
? string | null | undefined
|
|
784
|
+
: T[K] extends Types.DocumentArray<infer ItemType>
|
|
785
|
+
? Types.DocumentArray<DateToString<ItemType>>
|
|
786
|
+
: T[K] extends Types.Subdocument<unknown, unknown, infer SubdocType>
|
|
787
|
+
? HydratedSingleSubdocument<DateToString<SubdocType>>
|
|
788
|
+
: DateToString<T[K]>;
|
|
789
|
+
} : T;
|
|
782
790
|
|
|
783
791
|
/**
|
|
784
792
|
* Converts any Mongoose subdocuments (single nested or doc arrays) into POJO equivalents
|
|
785
793
|
*/
|
|
786
|
-
export type SubdocsToPOJOs<T> = T extends
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
:
|
|
792
|
-
|
|
794
|
+
export type SubdocsToPOJOs<T> = T extends Document
|
|
795
|
+
? T
|
|
796
|
+
: T extends TreatAsPrimitives
|
|
797
|
+
? T
|
|
798
|
+
: T extends Record<string, any> ? {
|
|
799
|
+
[K in keyof T]: T[K] extends Types.DocumentArray<infer ItemType>
|
|
800
|
+
? ItemType[]
|
|
801
|
+
: T[K] extends Types.Subdocument<unknown, unknown, infer SubdocType>
|
|
802
|
+
? SubdocType
|
|
803
|
+
: SubdocsToPOJOs<T[K]>;
|
|
804
|
+
} : T;
|
|
793
805
|
|
|
794
806
|
export type JSONSerialized<T> = SubdocsToPOJOs<
|
|
795
807
|
FlattenMaps<
|
package/types/indexes.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ declare module 'mongoose' {
|
|
|
10
10
|
function syncIndexes(options?: SyncIndexesOptions): Promise<ConnectionSyncIndexesResult>;
|
|
11
11
|
|
|
12
12
|
interface IndexManager {
|
|
13
|
+
/* Deletes all indexes that aren't defined in this model's schema. Used by `syncIndexes()`. Returns list of dropped index names. */
|
|
14
|
+
cleanIndexes(options?: { toDrop?: string[], hideIndexes?: boolean }): Promise<string[]>;
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#createIndex)
|
|
15
18
|
* function.
|
package/types/models.d.ts
CHANGED
|
@@ -333,7 +333,7 @@ declare module 'mongoose' {
|
|
|
333
333
|
TQueryHelpers,
|
|
334
334
|
TRawDocType,
|
|
335
335
|
'countDocuments',
|
|
336
|
-
TInstanceMethods
|
|
336
|
+
TInstanceMethods & TVirtuals
|
|
337
337
|
>;
|
|
338
338
|
|
|
339
339
|
/** Creates a new document or documents */
|
|
@@ -372,7 +372,7 @@ declare module 'mongoose' {
|
|
|
372
372
|
TQueryHelpers,
|
|
373
373
|
TRawDocType,
|
|
374
374
|
'deleteMany',
|
|
375
|
-
TInstanceMethods
|
|
375
|
+
TInstanceMethods & TVirtuals
|
|
376
376
|
>;
|
|
377
377
|
deleteMany(
|
|
378
378
|
filter: RootFilterQuery<TRawDocType>
|
|
@@ -382,7 +382,7 @@ declare module 'mongoose' {
|
|
|
382
382
|
TQueryHelpers,
|
|
383
383
|
TRawDocType,
|
|
384
384
|
'deleteMany',
|
|
385
|
-
TInstanceMethods
|
|
385
|
+
TInstanceMethods & TVirtuals
|
|
386
386
|
>;
|
|
387
387
|
|
|
388
388
|
/**
|
|
@@ -399,7 +399,7 @@ declare module 'mongoose' {
|
|
|
399
399
|
TQueryHelpers,
|
|
400
400
|
TRawDocType,
|
|
401
401
|
'deleteOne',
|
|
402
|
-
TInstanceMethods
|
|
402
|
+
TInstanceMethods & TVirtuals
|
|
403
403
|
>;
|
|
404
404
|
deleteOne(
|
|
405
405
|
filter: RootFilterQuery<TRawDocType>
|
|
@@ -409,7 +409,7 @@ declare module 'mongoose' {
|
|
|
409
409
|
TQueryHelpers,
|
|
410
410
|
TRawDocType,
|
|
411
411
|
'deleteOne',
|
|
412
|
-
TInstanceMethods
|
|
412
|
+
TInstanceMethods & TVirtuals
|
|
413
413
|
>;
|
|
414
414
|
|
|
415
415
|
/**
|
|
@@ -439,17 +439,17 @@ declare module 'mongoose' {
|
|
|
439
439
|
TQueryHelpers,
|
|
440
440
|
TRawDocType,
|
|
441
441
|
'findOne',
|
|
442
|
-
TInstanceMethods
|
|
442
|
+
TInstanceMethods & TVirtuals
|
|
443
443
|
>;
|
|
444
444
|
findById<ResultDoc = THydratedDocumentType>(
|
|
445
445
|
id: any,
|
|
446
446
|
projection?: ProjectionType<TRawDocType> | null,
|
|
447
447
|
options?: QueryOptions<TRawDocType> | null
|
|
448
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
|
448
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods & TVirtuals>;
|
|
449
449
|
findById<ResultDoc = THydratedDocumentType>(
|
|
450
450
|
id: any,
|
|
451
451
|
projection?: ProjectionType<TRawDocType> | null
|
|
452
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
|
452
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods & TVirtuals>;
|
|
453
453
|
|
|
454
454
|
/** Finds one document. */
|
|
455
455
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
@@ -462,20 +462,20 @@ declare module 'mongoose' {
|
|
|
462
462
|
TQueryHelpers,
|
|
463
463
|
TRawDocType,
|
|
464
464
|
'findOne',
|
|
465
|
-
TInstanceMethods
|
|
465
|
+
TInstanceMethods & TVirtuals
|
|
466
466
|
>;
|
|
467
467
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
468
468
|
filter?: RootFilterQuery<TRawDocType>,
|
|
469
469
|
projection?: ProjectionType<TRawDocType> | null,
|
|
470
470
|
options?: QueryOptions<TRawDocType> | null
|
|
471
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
|
471
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods & TVirtuals>;
|
|
472
472
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
473
473
|
filter?: RootFilterQuery<TRawDocType>,
|
|
474
474
|
projection?: ProjectionType<TRawDocType> | null
|
|
475
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
|
475
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods & TVirtuals>;
|
|
476
476
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
477
477
|
filter?: RootFilterQuery<TRawDocType>
|
|
478
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
|
478
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods & TVirtuals>;
|
|
479
479
|
|
|
480
480
|
/**
|
|
481
481
|
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
@@ -617,7 +617,7 @@ declare module 'mongoose' {
|
|
|
617
617
|
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>;
|
|
618
618
|
|
|
619
619
|
/** Adds a `$where` clause to this query */
|
|
620
|
-
$where(argument: string | Function): QueryWithHelpers<Array<THydratedDocumentType>, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
|
620
|
+
$where(argument: string | Function): QueryWithHelpers<Array<THydratedDocumentType>, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find', TInstanceMethods & TVirtuals>;
|
|
621
621
|
|
|
622
622
|
/** Registered discriminators for this model. */
|
|
623
623
|
discriminators: { [name: string]: Model<any> } | undefined;
|
|
@@ -640,7 +640,7 @@ declare module 'mongoose' {
|
|
|
640
640
|
TQueryHelpers,
|
|
641
641
|
TRawDocType,
|
|
642
642
|
'distinct',
|
|
643
|
-
TInstanceMethods
|
|
643
|
+
TInstanceMethods & TVirtuals
|
|
644
644
|
>;
|
|
645
645
|
|
|
646
646
|
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
@@ -650,7 +650,7 @@ declare module 'mongoose' {
|
|
|
650
650
|
TQueryHelpers,
|
|
651
651
|
TRawDocType,
|
|
652
652
|
'estimatedDocumentCount',
|
|
653
|
-
TInstanceMethods
|
|
653
|
+
TInstanceMethods & TVirtuals
|
|
654
654
|
>;
|
|
655
655
|
|
|
656
656
|
/**
|
|
@@ -665,7 +665,7 @@ declare module 'mongoose' {
|
|
|
665
665
|
TQueryHelpers,
|
|
666
666
|
TRawDocType,
|
|
667
667
|
'findOne',
|
|
668
|
-
TInstanceMethods
|
|
668
|
+
TInstanceMethods & TVirtuals
|
|
669
669
|
>;
|
|
670
670
|
|
|
671
671
|
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
@@ -679,22 +679,22 @@ declare module 'mongoose' {
|
|
|
679
679
|
TQueryHelpers,
|
|
680
680
|
TRawDocType,
|
|
681
681
|
'find',
|
|
682
|
-
TInstanceMethods
|
|
682
|
+
TInstanceMethods & TVirtuals
|
|
683
683
|
>;
|
|
684
684
|
find<ResultDoc = THydratedDocumentType>(
|
|
685
685
|
filter: RootFilterQuery<TRawDocType>,
|
|
686
686
|
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
687
687
|
options?: QueryOptions<TRawDocType> | null | undefined
|
|
688
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
|
688
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods & TVirtuals>;
|
|
689
689
|
find<ResultDoc = THydratedDocumentType>(
|
|
690
690
|
filter: RootFilterQuery<TRawDocType>,
|
|
691
691
|
projection?: ProjectionType<TRawDocType> | null | undefined
|
|
692
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
|
692
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods & TVirtuals>;
|
|
693
693
|
find<ResultDoc = THydratedDocumentType>(
|
|
694
694
|
filter: RootFilterQuery<TRawDocType>
|
|
695
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
|
695
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods & TVirtuals>;
|
|
696
696
|
find<ResultDoc = THydratedDocumentType>(
|
|
697
|
-
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
|
697
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods & TVirtuals>;
|
|
698
698
|
|
|
699
699
|
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
700
700
|
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
@@ -706,16 +706,16 @@ declare module 'mongoose' {
|
|
|
706
706
|
TQueryHelpers,
|
|
707
707
|
TRawDocType,
|
|
708
708
|
'findOneAndDelete',
|
|
709
|
-
TInstanceMethods
|
|
709
|
+
TInstanceMethods & TVirtuals
|
|
710
710
|
>;
|
|
711
711
|
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
712
712
|
id: mongodb.ObjectId | any,
|
|
713
713
|
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
714
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
|
714
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods & TVirtuals>;
|
|
715
715
|
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
716
716
|
id?: mongodb.ObjectId | any,
|
|
717
717
|
options?: QueryOptions<TRawDocType> | null
|
|
718
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
|
718
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods & TVirtuals>;
|
|
719
719
|
|
|
720
720
|
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
721
721
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
@@ -728,7 +728,7 @@ declare module 'mongoose' {
|
|
|
728
728
|
TQueryHelpers,
|
|
729
729
|
TRawDocType,
|
|
730
730
|
'findOneAndUpdate',
|
|
731
|
-
TInstanceMethods
|
|
731
|
+
TInstanceMethods & TVirtuals
|
|
732
732
|
>;
|
|
733
733
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
734
734
|
id: mongodb.ObjectId | any,
|
|
@@ -740,27 +740,27 @@ declare module 'mongoose' {
|
|
|
740
740
|
TQueryHelpers,
|
|
741
741
|
TRawDocType,
|
|
742
742
|
'findOneAndUpdate',
|
|
743
|
-
TInstanceMethods
|
|
743
|
+
TInstanceMethods & TVirtuals
|
|
744
744
|
>;
|
|
745
745
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
746
746
|
id: mongodb.ObjectId | any,
|
|
747
747
|
update: UpdateQuery<TRawDocType>,
|
|
748
748
|
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
749
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
|
749
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods & TVirtuals>;
|
|
750
750
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
751
751
|
id: mongodb.ObjectId | any,
|
|
752
752
|
update: UpdateQuery<TRawDocType>,
|
|
753
753
|
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
754
|
-
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
|
754
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods & TVirtuals>;
|
|
755
755
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
756
756
|
id?: mongodb.ObjectId | any,
|
|
757
757
|
update?: UpdateQuery<TRawDocType>,
|
|
758
758
|
options?: QueryOptions<TRawDocType> | null
|
|
759
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
|
759
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods & TVirtuals>;
|
|
760
760
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
761
761
|
id: mongodb.ObjectId | any,
|
|
762
762
|
update: UpdateQuery<TRawDocType>
|
|
763
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
|
763
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods & TVirtuals>;
|
|
764
764
|
|
|
765
765
|
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
766
766
|
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
@@ -772,16 +772,16 @@ declare module 'mongoose' {
|
|
|
772
772
|
TQueryHelpers,
|
|
773
773
|
TRawDocType,
|
|
774
774
|
'findOneAndDelete',
|
|
775
|
-
TInstanceMethods
|
|
775
|
+
TInstanceMethods & TVirtuals
|
|
776
776
|
>;
|
|
777
777
|
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
778
778
|
filter: RootFilterQuery<TRawDocType>,
|
|
779
779
|
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
780
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
|
780
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods & TVirtuals>;
|
|
781
781
|
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
782
782
|
filter?: RootFilterQuery<TRawDocType> | null,
|
|
783
783
|
options?: QueryOptions<TRawDocType> | null
|
|
784
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
|
784
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods & TVirtuals>;
|
|
785
785
|
|
|
786
786
|
/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
|
|
787
787
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
@@ -794,23 +794,23 @@ declare module 'mongoose' {
|
|
|
794
794
|
TQueryHelpers,
|
|
795
795
|
TRawDocType,
|
|
796
796
|
'findOneAndReplace',
|
|
797
|
-
TInstanceMethods
|
|
797
|
+
TInstanceMethods & TVirtuals
|
|
798
798
|
>;
|
|
799
799
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
800
800
|
filter: RootFilterQuery<TRawDocType>,
|
|
801
801
|
replacement: TRawDocType | AnyObject,
|
|
802
802
|
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
803
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods>;
|
|
803
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods & TVirtuals>;
|
|
804
804
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
805
805
|
filter: RootFilterQuery<TRawDocType>,
|
|
806
806
|
replacement: TRawDocType | AnyObject,
|
|
807
807
|
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
808
|
-
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods>;
|
|
808
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods & TVirtuals>;
|
|
809
809
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
810
810
|
filter?: RootFilterQuery<TRawDocType>,
|
|
811
811
|
replacement?: TRawDocType | AnyObject,
|
|
812
812
|
options?: QueryOptions<TRawDocType> | null
|
|
813
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods>;
|
|
813
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods & TVirtuals>;
|
|
814
814
|
|
|
815
815
|
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
816
816
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
@@ -823,7 +823,7 @@ declare module 'mongoose' {
|
|
|
823
823
|
TQueryHelpers,
|
|
824
824
|
TRawDocType,
|
|
825
825
|
'findOneAndUpdate',
|
|
826
|
-
TInstanceMethods
|
|
826
|
+
TInstanceMethods & TVirtuals
|
|
827
827
|
>;
|
|
828
828
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
829
829
|
filter: RootFilterQuery<TRawDocType>,
|
|
@@ -835,30 +835,30 @@ declare module 'mongoose' {
|
|
|
835
835
|
TQueryHelpers,
|
|
836
836
|
TRawDocType,
|
|
837
837
|
'findOneAndUpdate',
|
|
838
|
-
TInstanceMethods
|
|
838
|
+
TInstanceMethods & TVirtuals
|
|
839
839
|
>;
|
|
840
840
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
841
841
|
filter: RootFilterQuery<TRawDocType>,
|
|
842
842
|
update: UpdateQuery<TRawDocType>,
|
|
843
843
|
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
844
|
-
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
|
844
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods & TVirtuals>;
|
|
845
845
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
846
846
|
filter: RootFilterQuery<TRawDocType>,
|
|
847
847
|
update: UpdateQuery<TRawDocType>,
|
|
848
848
|
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
849
|
-
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
|
849
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods & TVirtuals>;
|
|
850
850
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
851
851
|
filter?: RootFilterQuery<TRawDocType>,
|
|
852
852
|
update?: UpdateQuery<TRawDocType>,
|
|
853
853
|
options?: QueryOptions<TRawDocType> | null
|
|
854
|
-
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
|
854
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods & TVirtuals>;
|
|
855
855
|
|
|
856
856
|
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
857
857
|
replaceOne<ResultDoc = THydratedDocumentType>(
|
|
858
858
|
filter?: RootFilterQuery<TRawDocType>,
|
|
859
859
|
replacement?: TRawDocType | AnyObject,
|
|
860
860
|
options?: (mongodb.ReplaceOptions & MongooseQueryOptions<TRawDocType>) | null
|
|
861
|
-
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'replaceOne', TInstanceMethods>;
|
|
861
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'replaceOne', TInstanceMethods & TVirtuals>;
|
|
862
862
|
|
|
863
863
|
/** Apply changes made to this model's schema after this model was compiled. */
|
|
864
864
|
recompileSchema(): void;
|
|
@@ -871,14 +871,14 @@ declare module 'mongoose' {
|
|
|
871
871
|
filter?: RootFilterQuery<TRawDocType>,
|
|
872
872
|
update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
873
873
|
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
874
|
-
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateMany', TInstanceMethods>;
|
|
874
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateMany', TInstanceMethods & TVirtuals>;
|
|
875
875
|
|
|
876
876
|
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
877
877
|
updateOne<ResultDoc = THydratedDocumentType>(
|
|
878
878
|
filter?: RootFilterQuery<TRawDocType>,
|
|
879
879
|
update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
880
880
|
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
881
|
-
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateOne', TInstanceMethods>;
|
|
881
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateOne', TInstanceMethods & TVirtuals>;
|
|
882
882
|
|
|
883
883
|
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
884
884
|
where<ResultDoc = THydratedDocumentType>(
|
|
@@ -891,7 +891,7 @@ declare module 'mongoose' {
|
|
|
891
891
|
TQueryHelpers,
|
|
892
892
|
TRawDocType,
|
|
893
893
|
'find',
|
|
894
|
-
TInstanceMethods
|
|
894
|
+
TInstanceMethods & TVirtuals
|
|
895
895
|
>;
|
|
896
896
|
where<ResultDoc = THydratedDocumentType>(): QueryWithHelpers<
|
|
897
897
|
Array<ResultDoc>,
|
|
@@ -899,7 +899,7 @@ declare module 'mongoose' {
|
|
|
899
899
|
TQueryHelpers,
|
|
900
900
|
TRawDocType,
|
|
901
901
|
'find',
|
|
902
|
-
TInstanceMethods
|
|
902
|
+
TInstanceMethods & TVirtuals
|
|
903
903
|
>;
|
|
904
904
|
}
|
|
905
905
|
}
|