mongoose 7.4.2 → 7.4.4
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 +49 -32
- package/lib/cursor/ChangeStream.js +13 -2
- package/lib/helpers/query/selectPopulatedFields.js +13 -0
- package/lib/helpers/schema/getIndexes.js +9 -1
- package/lib/queryhelpers.js +1 -1
- package/lib/schema.js +8 -0
- package/lib/utils.js +14 -1
- package/package.json +1 -1
- package/types/document.d.ts +12 -0
- package/types/index.d.ts +46 -17
- package/types/inferschematype.d.ts +3 -3
- package/types/middlewares.d.ts +10 -2
- package/types/models.d.ts +111 -0
- package/types/query.d.ts +16 -2
package/types/query.d.ts
CHANGED
|
@@ -179,6 +179,10 @@ declare module 'mongoose' {
|
|
|
179
179
|
|
|
180
180
|
type QueryOpThatReturnsDocument = 'find' | 'findOne' | 'findOneAndUpdate' | 'findOneAndReplace' | 'findOneAndDelete';
|
|
181
181
|
|
|
182
|
+
type GetLeanResultType<RawDocType, ResultType, QueryOp> = QueryOp extends QueryOpThatReturnsDocument
|
|
183
|
+
? (ResultType extends any[] ? Require_id<FlattenMaps<RawDocType>>[] : Require_id<FlattenMaps<RawDocType>>)
|
|
184
|
+
: ResultType;
|
|
185
|
+
|
|
182
186
|
class Query<ResultType, DocType, THelpers = {}, RawDocType = DocType, QueryOp = 'find'> implements SessionOperation {
|
|
183
187
|
_mongooseOptions: MongooseQueryOptions<DocType>;
|
|
184
188
|
|
|
@@ -499,9 +503,19 @@ declare module 'mongoose' {
|
|
|
499
503
|
j(val: boolean | null): this;
|
|
500
504
|
|
|
501
505
|
/** Sets the lean option. */
|
|
502
|
-
lean<
|
|
506
|
+
lean<
|
|
507
|
+
LeanResultType = GetLeanResultType<RawDocType, ResultType, QueryOp>
|
|
508
|
+
>(
|
|
503
509
|
val?: boolean | any
|
|
504
|
-
): QueryWithHelpers<
|
|
510
|
+
): QueryWithHelpers<
|
|
511
|
+
ResultType extends null
|
|
512
|
+
? LeanResultType | null
|
|
513
|
+
: LeanResultType,
|
|
514
|
+
DocType,
|
|
515
|
+
THelpers,
|
|
516
|
+
RawDocType,
|
|
517
|
+
QueryOp
|
|
518
|
+
>;
|
|
505
519
|
|
|
506
520
|
/** Specifies the maximum number of documents the query will return. */
|
|
507
521
|
limit(val: number): this;
|