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/types/models.d.ts CHANGED
@@ -158,13 +158,19 @@ declare module 'mongoose' {
158
158
  MongooseBulkUpdatePerOperationOptions;
159
159
 
160
160
  export type UpdateOneModel<TSchema extends mongodb.Document = mongodb.Document> =
161
- Omit<mongodb.UpdateOneModel<TSchema>, 'filter'> &
162
- { filter: QueryFilter<TSchema> } &
161
+ Omit<mongodb.UpdateOneModel<TSchema>, 'filter' | 'update'> &
162
+ {
163
+ filter: QueryFilter<TSchema>;
164
+ update: UpdateQuery<TSchema> | UpdateWithAggregationPipeline;
165
+ } &
163
166
  MongooseBulkUpdatePerOperationOptions;
164
167
 
165
168
  export type UpdateManyModel<TSchema extends mongodb.Document = mongodb.Document> =
166
- Omit<mongodb.UpdateManyModel<TSchema>, 'filter'> &
167
- { filter: QueryFilter<TSchema> } &
169
+ Omit<mongodb.UpdateManyModel<TSchema>, 'filter' | 'update'> &
170
+ {
171
+ filter: QueryFilter<TSchema>;
172
+ update: UpdateQuery<TSchema> | UpdateWithAggregationPipeline;
173
+ } &
168
174
  MongooseBulkUpdatePerOperationOptions;
169
175
 
170
176
  export type DeleteOneModel<TSchema extends mongodb.Document = mongodb.Document> =
@@ -228,7 +234,7 @@ declare module 'mongoose' {
228
234
  TVirtuals = {},
229
235
  THydratedDocumentType = HydratedDocument<TRawDocType, TVirtuals & TInstanceMethods, TQueryHelpers, TVirtuals>,
230
236
  TSchema = any,
231
- TLeanResultType = TRawDocType> extends
237
+ TLeanResultType = Default__v<Require_id<TRawDocType>>> extends
232
238
  NodeJS.EventEmitter,
233
239
  IndexManager,
234
240
  SessionStarter {
@@ -455,7 +461,8 @@ declare module 'mongoose' {
455
461
  TQueryHelpers,
456
462
  TLeanResultType,
457
463
  'findOne',
458
- TInstanceMethods & TVirtuals
464
+ TInstanceMethods & TVirtuals,
465
+ ApplyProjection<TLeanResultType, Projection>
459
466
  >;
460
467
  findById<ResultDoc = THydratedDocumentType>(
461
468
  id: any,
@@ -505,7 +512,8 @@ declare module 'mongoose' {
505
512
  TQueryHelpers,
506
513
  TLeanResultType,
507
514
  'findOne',
508
- TInstanceMethods & TVirtuals
515
+ TInstanceMethods & TVirtuals,
516
+ ApplyProjection<TLeanResultType, Projection>
509
517
  >;
510
518
  findOne<const Projection extends ProjectionType<TRawDocType>>(
511
519
  filter: QueryFilter<TRawDocType>,
@@ -517,7 +525,8 @@ declare module 'mongoose' {
517
525
  TQueryHelpers,
518
526
  TLeanResultType,
519
527
  'findOne',
520
- TInstanceMethods & TVirtuals
528
+ TInstanceMethods & TVirtuals,
529
+ ApplyProjection<TLeanResultType, Projection>
521
530
  >;
522
531
  findOne<const Projection extends ProjectionType<TRawDocType>>(
523
532
  filter: QueryFilter<TRawDocType>,
@@ -529,7 +538,8 @@ declare module 'mongoose' {
529
538
  TQueryHelpers,
530
539
  TLeanResultType,
531
540
  'findOne',
532
- TInstanceMethods & TVirtuals
541
+ TInstanceMethods & TVirtuals,
542
+ ApplyProjection<TLeanResultType, Projection>
533
543
  >;
534
544
  findOne<const Projection extends ProjectionType<TRawDocType>>(
535
545
  filter: QueryFilter<TRawDocType>,
@@ -541,7 +551,8 @@ declare module 'mongoose' {
541
551
  TQueryHelpers,
542
552
  TLeanResultType,
543
553
  'findOne',
544
- TInstanceMethods & TVirtuals
554
+ TInstanceMethods & TVirtuals,
555
+ ApplyProjection<TLeanResultType, Projection>
545
556
  >;
546
557
  findOne<ResultDoc = THydratedDocumentType>(
547
558
  filter: QueryFilter<TRawDocType>,
@@ -850,7 +861,8 @@ declare module 'mongoose' {
850
861
  TQueryHelpers,
851
862
  TLeanResultType,
852
863
  'find',
853
- TInstanceMethods & TVirtuals
864
+ TInstanceMethods & TVirtuals,
865
+ ApplyProjection<TLeanResultType, Projection>
854
866
  >;
855
867
  find<const Projection extends ProjectionType<TRawDocType>>(
856
868
  filter: QueryFilter<TRawDocType>,
@@ -862,7 +874,8 @@ declare module 'mongoose' {
862
874
  TQueryHelpers,
863
875
  TLeanResultType,
864
876
  'find',
865
- TInstanceMethods & TVirtuals
877
+ TInstanceMethods & TVirtuals,
878
+ ApplyProjection<TLeanResultType, Projection>
866
879
  >;
867
880
  find<const Projection extends ProjectionType<TRawDocType>>(
868
881
  filter: QueryFilter<TRawDocType>,
@@ -874,7 +887,8 @@ declare module 'mongoose' {
874
887
  TQueryHelpers,
875
888
  TLeanResultType,
876
889
  'find',
877
- TInstanceMethods & TVirtuals
890
+ TInstanceMethods & TVirtuals,
891
+ ApplyProjection<TLeanResultType, Projection>
878
892
  >;
879
893
  find<const Projection extends ProjectionType<TRawDocType>>(
880
894
  filter: QueryFilter<TRawDocType>,
@@ -886,14 +900,15 @@ declare module 'mongoose' {
886
900
  TQueryHelpers,
887
901
  TLeanResultType,
888
902
  'find',
889
- TInstanceMethods & TVirtuals
903
+ TInstanceMethods & TVirtuals,
904
+ ApplyProjection<TLeanResultType, Projection>
890
905
  >;
891
906
  find<ResultDoc = THydratedDocumentType>(
892
907
  filter: QueryFilter<TRawDocType>,
893
908
  projection: ProjectionType<TRawDocType> | null | undefined,
894
909
  options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
895
910
  ): QueryWithHelpers<
896
- GetLeanResultType<TRawDocType, TRawDocType[], 'find'>,
911
+ GetLeanResultType<TLeanResultType, TRawDocType[], 'find'>,
897
912
  ResultDoc,
898
913
  TQueryHelpers,
899
914
  TLeanResultType,
@@ -905,7 +920,7 @@ declare module 'mongoose' {
905
920
  projection: ProjectionType<TRawDocType> | null | undefined,
906
921
  options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
907
922
  ): QueryWithHelpers<
908
- GetLeanResultType<TRawDocType, TRawDocType[], 'find'>,
923
+ GetLeanResultType<TLeanResultType, TRawDocType[], 'find'>,
909
924
  THydratedDocumentType,
910
925
  TQueryHelpers,
911
926
  TLeanResultType,
@@ -959,7 +974,7 @@ declare module 'mongoose' {
959
974
  filter: QueryFilter<TRawDocType>,
960
975
  projection: ProjectionType<TRawDocType> | null | undefined,
961
976
  options: QueryOptions<TRawDocType> & { sort: any; limit: number; lean: true } & mongodb.Abortable
962
- ): Promise<[GetLeanResultType<TRawDocType, TRawDocType[], 'find'>, number]>;
977
+ ): Promise<[GetLeanResultType<TLeanResultType, TRawDocType[], 'find'>, number]>;
963
978
  findAndCount<ResultDoc = THydratedDocumentType>(
964
979
  filter: QueryFilter<TRawDocType>,
965
980
  projection: ProjectionType<TRawDocType> | null | undefined,
@@ -981,7 +996,8 @@ declare module 'mongoose' {
981
996
  TQueryHelpers,
982
997
  TLeanResultType,
983
998
  'findOneAndDelete',
984
- TInstanceMethods & TVirtuals
999
+ TInstanceMethods & TVirtuals,
1000
+ ApplyProjection<TLeanResultType, Projection>
985
1001
  >;
986
1002
  findByIdAndDelete<const Projection extends ProjectionType<TRawDocType>>(
987
1003
  id: mongodb.ObjectId | any,
@@ -992,7 +1008,8 @@ declare module 'mongoose' {
992
1008
  TQueryHelpers,
993
1009
  TLeanResultType,
994
1010
  'findOneAndDelete',
995
- TInstanceMethods & TVirtuals
1011
+ TInstanceMethods & TVirtuals,
1012
+ ApplyProjection<TLeanResultType, Projection>
996
1013
  >;
997
1014
  findByIdAndDelete<ResultDoc = THydratedDocumentType>(
998
1015
  id: mongodb.ObjectId | any,
@@ -1062,7 +1079,8 @@ declare module 'mongoose' {
1062
1079
  TQueryHelpers,
1063
1080
  TLeanResultType,
1064
1081
  'findOneAndUpdate',
1065
- TInstanceMethods & TVirtuals
1082
+ TInstanceMethods & TVirtuals,
1083
+ ApplyProjection<TLeanResultType, Projection>
1066
1084
  >;
1067
1085
  findByIdAndUpdate<const Projection extends ProjectionType<TRawDocType>>(
1068
1086
  id: mongodb.ObjectId | any,
@@ -1074,7 +1092,8 @@ declare module 'mongoose' {
1074
1092
  TQueryHelpers,
1075
1093
  TLeanResultType,
1076
1094
  'findOneAndUpdate',
1077
- TInstanceMethods & TVirtuals
1095
+ TInstanceMethods & TVirtuals,
1096
+ ApplyProjection<TLeanResultType, Projection>
1078
1097
  >;
1079
1098
  findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
1080
1099
  filter: QueryFilter<TRawDocType>,
@@ -1171,7 +1190,8 @@ declare module 'mongoose' {
1171
1190
  TQueryHelpers,
1172
1191
  TLeanResultType,
1173
1192
  'findOneAndDelete',
1174
- TInstanceMethods & TVirtuals
1193
+ TInstanceMethods & TVirtuals,
1194
+ ApplyProjection<TLeanResultType, Projection>
1175
1195
  >;
1176
1196
  findOneAndDelete<const Projection extends ProjectionType<TRawDocType>>(
1177
1197
  filter: QueryFilter<TRawDocType>,
@@ -1182,7 +1202,8 @@ declare module 'mongoose' {
1182
1202
  TQueryHelpers,
1183
1203
  TLeanResultType,
1184
1204
  'findOneAndDelete',
1185
- TInstanceMethods & TVirtuals
1205
+ TInstanceMethods & TVirtuals,
1206
+ ApplyProjection<TLeanResultType, Projection>
1186
1207
  >;
1187
1208
  findOneAndDelete<const Projection extends ProjectionType<TRawDocType>>(
1188
1209
  filter: QueryFilter<TRawDocType>,
@@ -1193,7 +1214,8 @@ declare module 'mongoose' {
1193
1214
  TQueryHelpers,
1194
1215
  TLeanResultType,
1195
1216
  'findOneAndDelete',
1196
- TInstanceMethods & TVirtuals
1217
+ TInstanceMethods & TVirtuals,
1218
+ ApplyProjection<TLeanResultType, Projection>
1197
1219
  >;
1198
1220
  findOneAndDelete<const Projection extends ProjectionType<TRawDocType>>(
1199
1221
  filter: QueryFilter<TRawDocType>,
@@ -1204,7 +1226,8 @@ declare module 'mongoose' {
1204
1226
  TQueryHelpers,
1205
1227
  TLeanResultType,
1206
1228
  'findOneAndDelete',
1207
- TInstanceMethods & TVirtuals
1229
+ TInstanceMethods & TVirtuals,
1230
+ ApplyProjection<TLeanResultType, Projection>
1208
1231
  >;
1209
1232
  findOneAndDelete<ResultDoc = THydratedDocumentType>(
1210
1233
  filter: QueryFilter<TRawDocType>,
@@ -1306,7 +1329,8 @@ declare module 'mongoose' {
1306
1329
  TQueryHelpers,
1307
1330
  TLeanResultType,
1308
1331
  'findOneAndReplace',
1309
- TInstanceMethods & TVirtuals
1332
+ TInstanceMethods & TVirtuals,
1333
+ ApplyProjection<TLeanResultType, Projection>
1310
1334
  >;
1311
1335
  findOneAndReplace<const Projection extends ProjectionType<TRawDocType>>(
1312
1336
  filter: QueryFilter<TRawDocType>,
@@ -1318,7 +1342,8 @@ declare module 'mongoose' {
1318
1342
  TQueryHelpers,
1319
1343
  TLeanResultType,
1320
1344
  'findOneAndReplace',
1321
- TInstanceMethods & TVirtuals
1345
+ TInstanceMethods & TVirtuals,
1346
+ ApplyProjection<TLeanResultType, Projection>
1322
1347
  >;
1323
1348
  findOneAndReplace<const Projection extends ProjectionType<TRawDocType>>(
1324
1349
  filter: QueryFilter<TRawDocType>,
@@ -1330,7 +1355,8 @@ declare module 'mongoose' {
1330
1355
  TQueryHelpers,
1331
1356
  TLeanResultType,
1332
1357
  'findOneAndReplace',
1333
- TInstanceMethods & TVirtuals
1358
+ TInstanceMethods & TVirtuals,
1359
+ ApplyProjection<TLeanResultType, Projection>
1334
1360
  >;
1335
1361
  findOneAndReplace<const Projection extends ProjectionType<TRawDocType>>(
1336
1362
  filter: QueryFilter<TRawDocType>,
@@ -1342,7 +1368,8 @@ declare module 'mongoose' {
1342
1368
  TQueryHelpers,
1343
1369
  TLeanResultType,
1344
1370
  'findOneAndReplace',
1345
- TInstanceMethods & TVirtuals
1371
+ TInstanceMethods & TVirtuals,
1372
+ ApplyProjection<TLeanResultType, Projection>
1346
1373
  >;
1347
1374
  findOneAndReplace<ResultDoc = THydratedDocumentType>(
1348
1375
  filter: QueryFilter<TRawDocType>,
@@ -1476,7 +1503,8 @@ declare module 'mongoose' {
1476
1503
  TQueryHelpers,
1477
1504
  TLeanResultType,
1478
1505
  'findOneAndUpdate',
1479
- TInstanceMethods & TVirtuals
1506
+ TInstanceMethods & TVirtuals,
1507
+ ApplyProjection<TLeanResultType, Projection>
1480
1508
  >;
1481
1509
  findOneAndUpdate<const Projection extends ProjectionType<TRawDocType>>(
1482
1510
  filter: QueryFilter<TRawDocType>,
@@ -1488,7 +1516,8 @@ declare module 'mongoose' {
1488
1516
  TQueryHelpers,
1489
1517
  TLeanResultType,
1490
1518
  'findOneAndUpdate',
1491
- TInstanceMethods & TVirtuals
1519
+ TInstanceMethods & TVirtuals,
1520
+ ApplyProjection<TLeanResultType, Projection>
1492
1521
  >;
1493
1522
  findOneAndUpdate<const Projection extends ProjectionType<TRawDocType>>(
1494
1523
  filter: QueryFilter<TRawDocType>,
@@ -1500,7 +1529,8 @@ declare module 'mongoose' {
1500
1529
  TQueryHelpers,
1501
1530
  TLeanResultType,
1502
1531
  'findOneAndUpdate',
1503
- TInstanceMethods & TVirtuals
1532
+ TInstanceMethods & TVirtuals,
1533
+ ApplyProjection<TLeanResultType, Projection>
1504
1534
  >;
1505
1535
  findOneAndUpdate<const Projection extends ProjectionType<TRawDocType>>(
1506
1536
  filter: QueryFilter<TRawDocType>,
@@ -1512,7 +1542,8 @@ declare module 'mongoose' {
1512
1542
  TQueryHelpers,
1513
1543
  TLeanResultType,
1514
1544
  'findOneAndUpdate',
1515
- TInstanceMethods & TVirtuals
1545
+ TInstanceMethods & TVirtuals,
1546
+ ApplyProjection<TLeanResultType, Projection>
1516
1547
  >;
1517
1548
  findOneAndUpdate<ResultDoc = THydratedDocumentType>(
1518
1549
  filter: QueryFilter<TRawDocType>,
@@ -1543,7 +1574,7 @@ declare module 'mongoose' {
1543
1574
  update: UpdateQuery<TRawDocType>,
1544
1575
  options: QueryOptions<TRawDocType> & { lean: true }
1545
1576
  ): QueryWithHelpers<
1546
- GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndUpdate'> | null,
1577
+ GetLeanResultType<TLeanResultType, TRawDocType, 'findOneAndUpdate'> | null,
1547
1578
  ResultDoc,
1548
1579
  TQueryHelpers,
1549
1580
  TLeanResultType,
@@ -1555,7 +1586,7 @@ declare module 'mongoose' {
1555
1586
  update: UpdateQuery<TRawDocType>,
1556
1587
  options: QueryOptions<TRawDocType> & { lean: true }
1557
1588
  ): QueryWithHelpers<
1558
- GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndUpdate'> | null,
1589
+ GetLeanResultType<TLeanResultType, TRawDocType, 'findOneAndUpdate'> | null,
1559
1590
  THydratedDocumentType,
1560
1591
  TQueryHelpers,
1561
1592
  TLeanResultType,