mongoose 9.0.0-rc1 → 9.0.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/README.md +1 -1
- package/lib/aggregate.js +1 -1
- package/lib/cast/double.js +1 -1
- package/lib/cast.js +1 -1
- package/lib/connection.js +10 -10
- package/lib/document.js +54 -17
- package/lib/drivers/node-mongodb-native/collection.js +16 -1
- package/lib/drivers/node-mongodb-native/connection.js +1 -1
- package/lib/helpers/common.js +1 -1
- package/lib/helpers/indexes/applySchemaCollation.js +1 -1
- package/lib/helpers/indexes/isDefaultIdIndex.js +1 -1
- package/lib/helpers/model/applyMethods.js +1 -1
- package/lib/helpers/model/castBulkWrite.js +13 -6
- package/lib/helpers/populate/getModelsMapForPopulate.js +3 -3
- package/lib/helpers/populate/modelNamesFromRefPath.js +1 -1
- package/lib/helpers/populate/removeDeselectedForeignField.js +1 -1
- package/lib/helpers/projection/applyProjection.js +2 -2
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +1 -1
- package/lib/helpers/setDefaultsOnInsert.js +2 -2
- package/lib/helpers/timestamps/setupTimestamps.js +1 -1
- package/lib/helpers/update/applyTimestampsToUpdate.js +38 -25
- package/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
- package/lib/model.js +8 -7
- package/lib/mongoose.js +3 -4
- package/lib/query.js +3 -3
- package/lib/schema/array.js +1 -1
- package/lib/schema/number.js +14 -2
- package/lib/schema/operators/text.js +1 -1
- package/lib/schema.js +21 -21
- package/lib/schemaType.js +8 -8
- package/lib/types/array/index.js +5 -5
- package/lib/types/documentArray/index.js +6 -6
- package/lib/types/objectid.js +1 -1
- package/lib/utils.js +12 -24
- package/lib/virtualType.js +1 -1
- package/package.json +8 -7
- package/types/index.d.ts +1 -0
- package/types/models.d.ts +314 -86
- package/types/query.d.ts +91 -1
- package/types/utility.d.ts +2 -2
package/types/models.d.ts
CHANGED
|
@@ -172,94 +172,47 @@ declare module 'mongoose' {
|
|
|
172
172
|
|
|
173
173
|
interface RemoveOptions extends SessionOption, Omit<mongodb.DeleteOptions, 'session'> {}
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
insertOne: InsertOneModel<TSchema>;
|
|
179
|
-
} | {
|
|
180
|
-
replaceOne: ReplaceOneModel<TSchema>;
|
|
181
|
-
} | {
|
|
182
|
-
updateOne: UpdateOneModel<TSchema>;
|
|
183
|
-
} | {
|
|
184
|
-
updateMany: UpdateManyModel<TSchema>;
|
|
185
|
-
} | {
|
|
186
|
-
deleteOne: DeleteOneModel<TSchema>;
|
|
187
|
-
} | {
|
|
188
|
-
deleteMany: DeleteManyModel<TSchema>;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export interface InsertOneModel<TSchema> {
|
|
192
|
-
document: mongodb.OptionalId<TSchema>;
|
|
175
|
+
interface MongooseBulkWritePerOperationOptions {
|
|
176
|
+
/** Skip validation for this operation. */
|
|
177
|
+
skipValidation?: boolean;
|
|
193
178
|
/** When false, do not add timestamps. When true, overrides the `timestamps` option set in the `bulkWrite` options. */
|
|
194
179
|
timestamps?: boolean;
|
|
195
180
|
}
|
|
196
181
|
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
|
|
202
|
-
/** Specifies a collation. */
|
|
203
|
-
collation?: mongodb.CollationOptions;
|
|
204
|
-
/** The index to use. If specified, then the query system will only consider plans using the hinted index. */
|
|
205
|
-
hint?: mongodb.Hint;
|
|
206
|
-
/** When true, creates a new document if no document matches the query. */
|
|
207
|
-
upsert?: boolean;
|
|
208
|
-
/** When false, do not add timestamps. When true, overrides the `timestamps` option set in the `bulkWrite` options. */
|
|
209
|
-
timestamps?: boolean;
|
|
182
|
+
interface MongooseBulkUpdatePerOperationOptions extends MongooseBulkWritePerOperationOptions {
|
|
183
|
+
/** When true, allows updating fields that are marked as `immutable` in the schema. */
|
|
184
|
+
overwriteImmutable?: boolean;
|
|
185
|
+
/** When false, do not set default values on insert. */
|
|
186
|
+
setDefaultsOnInsert?: boolean;
|
|
210
187
|
}
|
|
211
188
|
|
|
212
|
-
export
|
|
213
|
-
|
|
214
|
-
filter: QueryFilter<TSchema>;
|
|
215
|
-
/** A document or pipeline containing update operators. */
|
|
216
|
-
update: UpdateQuery<TSchema>;
|
|
217
|
-
/** A set of filters specifying to which array elements an update should apply. */
|
|
218
|
-
arrayFilters?: AnyObject[];
|
|
219
|
-
/** Specifies a collation. */
|
|
220
|
-
collation?: mongodb.CollationOptions;
|
|
221
|
-
/** The index to use. If specified, then the query system will only consider plans using the hinted index. */
|
|
222
|
-
hint?: mongodb.Hint;
|
|
223
|
-
/** When true, creates a new document if no document matches the query. */
|
|
224
|
-
upsert?: boolean;
|
|
225
|
-
/** When false, do not add timestamps. When true, overrides the `timestamps` option set in the `bulkWrite` options. */
|
|
226
|
-
timestamps?: boolean;
|
|
227
|
-
}
|
|
189
|
+
export type InsertOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
190
|
+
mongodb.InsertOneModel<TSchema> & MongooseBulkWritePerOperationOptions;
|
|
228
191
|
|
|
229
|
-
export
|
|
230
|
-
|
|
231
|
-
filter: QueryFilter<TSchema>;
|
|
232
|
-
/** A document or pipeline containing update operators. */
|
|
233
|
-
update: UpdateQuery<TSchema>;
|
|
234
|
-
/** A set of filters specifying to which array elements an update should apply. */
|
|
235
|
-
arrayFilters?: AnyObject[];
|
|
236
|
-
/** Specifies a collation. */
|
|
237
|
-
collation?: mongodb.CollationOptions;
|
|
238
|
-
/** The index to use. If specified, then the query system will only consider plans using the hinted index. */
|
|
239
|
-
hint?: mongodb.Hint;
|
|
240
|
-
/** When true, creates a new document if no document matches the query. */
|
|
241
|
-
upsert?: boolean;
|
|
242
|
-
/** When false, do not add timestamps. When true, overrides the `timestamps` option set in the `bulkWrite` options. */
|
|
243
|
-
timestamps?: boolean;
|
|
244
|
-
}
|
|
192
|
+
export type ReplaceOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
193
|
+
mongodb.ReplaceOneModel<TSchema> & MongooseBulkWritePerOperationOptions;
|
|
245
194
|
|
|
246
|
-
export
|
|
247
|
-
|
|
248
|
-
filter: QueryFilter<TSchema>;
|
|
249
|
-
/** Specifies a collation. */
|
|
250
|
-
collation?: mongodb.CollationOptions;
|
|
251
|
-
/** The index to use. If specified, then the query system will only consider plans using the hinted index. */
|
|
252
|
-
hint?: mongodb.Hint;
|
|
253
|
-
}
|
|
195
|
+
export type UpdateOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
196
|
+
mongodb.UpdateOneModel<TSchema> & MongooseBulkUpdatePerOperationOptions;
|
|
254
197
|
|
|
255
|
-
export
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
198
|
+
export type UpdateManyModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
199
|
+
mongodb.UpdateManyModel<TSchema> & MongooseBulkUpdatePerOperationOptions;
|
|
200
|
+
|
|
201
|
+
export type DeleteOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
202
|
+
mongodb.DeleteOneModel<TSchema>;
|
|
203
|
+
|
|
204
|
+
export type DeleteManyModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
205
|
+
mongodb.DeleteManyModel<TSchema>;
|
|
206
|
+
|
|
207
|
+
export type AnyBulkWriteOperation<TSchema extends mongodb.Document = mongodb.Document> =
|
|
208
|
+
| { insertOne: InsertOneModel<TSchema> }
|
|
209
|
+
| { replaceOne: ReplaceOneModel<TSchema> }
|
|
210
|
+
| { updateOne: UpdateOneModel<TSchema> }
|
|
211
|
+
| { updateMany: UpdateManyModel<TSchema> }
|
|
212
|
+
| { deleteOne: DeleteOneModel<TSchema> }
|
|
213
|
+
| { deleteMany: DeleteManyModel<TSchema> };
|
|
214
|
+
|
|
215
|
+
const Model: Model<any>;
|
|
263
216
|
|
|
264
217
|
/*
|
|
265
218
|
* Apply common casting logic to the given type, allowing:
|
|
@@ -338,13 +291,13 @@ declare module 'mongoose' {
|
|
|
338
291
|
* round trip to the MongoDB server.
|
|
339
292
|
*/
|
|
340
293
|
bulkWrite<DocContents = TRawDocType>(
|
|
341
|
-
writes: Array<AnyBulkWriteOperation<DocContents>>,
|
|
342
|
-
options: MongooseBulkWriteOptions & { ordered: false }
|
|
343
|
-
): Promise<
|
|
294
|
+
writes: Array<AnyBulkWriteOperation<DocContents extends mongodb.Document ? DocContents : any>>,
|
|
295
|
+
options: mongodb.BulkWriteOptions & MongooseBulkWriteOptions & { ordered: false }
|
|
296
|
+
): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[] } }>;
|
|
344
297
|
bulkWrite<DocContents = TRawDocType>(
|
|
345
|
-
writes: Array<AnyBulkWriteOperation<DocContents>>,
|
|
346
|
-
options?: MongooseBulkWriteOptions
|
|
347
|
-
): Promise<
|
|
298
|
+
writes: Array<AnyBulkWriteOperation<DocContents extends mongodb.Document ? DocContents : any>>,
|
|
299
|
+
options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions
|
|
300
|
+
): Promise<mongodb.BulkWriteResult>;
|
|
348
301
|
|
|
349
302
|
/**
|
|
350
303
|
* Sends multiple `save()` calls in a single `bulkWrite()`. This is faster than
|
|
@@ -368,6 +321,17 @@ declare module 'mongoose' {
|
|
|
368
321
|
'countDocuments',
|
|
369
322
|
TInstanceMethods & TVirtuals
|
|
370
323
|
>;
|
|
324
|
+
countDocuments(
|
|
325
|
+
filter?: Query<any, any>,
|
|
326
|
+
options?: (mongodb.CountOptions & MongooseBaseQueryOptions<TRawDocType> & mongodb.Abortable) | null
|
|
327
|
+
): QueryWithHelpers<
|
|
328
|
+
number,
|
|
329
|
+
THydratedDocumentType,
|
|
330
|
+
TQueryHelpers,
|
|
331
|
+
TRawDocType,
|
|
332
|
+
'countDocuments',
|
|
333
|
+
TInstanceMethods & TVirtuals
|
|
334
|
+
>;
|
|
371
335
|
|
|
372
336
|
/** Creates a new document or documents */
|
|
373
337
|
create(): Promise<null>;
|
|
@@ -414,6 +378,17 @@ declare module 'mongoose' {
|
|
|
414
378
|
'deleteMany',
|
|
415
379
|
TInstanceMethods & TVirtuals
|
|
416
380
|
>;
|
|
381
|
+
deleteMany(
|
|
382
|
+
filter?: Query<any, any>,
|
|
383
|
+
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
|
384
|
+
): QueryWithHelpers<
|
|
385
|
+
mongodb.DeleteResult,
|
|
386
|
+
THydratedDocumentType,
|
|
387
|
+
TQueryHelpers,
|
|
388
|
+
TLeanResultType,
|
|
389
|
+
'deleteMany',
|
|
390
|
+
TInstanceMethods & TVirtuals
|
|
391
|
+
>;
|
|
417
392
|
|
|
418
393
|
/**
|
|
419
394
|
* Deletes the first document that matches `conditions` from the collection.
|
|
@@ -431,6 +406,17 @@ declare module 'mongoose' {
|
|
|
431
406
|
'deleteOne',
|
|
432
407
|
TInstanceMethods & TVirtuals
|
|
433
408
|
>;
|
|
409
|
+
deleteOne(
|
|
410
|
+
filter?: Query<any, any>,
|
|
411
|
+
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
|
412
|
+
): QueryWithHelpers<
|
|
413
|
+
mongodb.DeleteResult,
|
|
414
|
+
THydratedDocumentType,
|
|
415
|
+
TQueryHelpers,
|
|
416
|
+
TLeanResultType,
|
|
417
|
+
'deleteOne',
|
|
418
|
+
TInstanceMethods & TVirtuals
|
|
419
|
+
>;
|
|
434
420
|
|
|
435
421
|
/** Adds a discriminator type. */
|
|
436
422
|
discriminator<TDiscriminatorSchema extends Schema<any, any>>(
|
|
@@ -509,6 +495,18 @@ declare module 'mongoose' {
|
|
|
509
495
|
'findOne',
|
|
510
496
|
TInstanceMethods & TVirtuals
|
|
511
497
|
>;
|
|
498
|
+
findOne(
|
|
499
|
+
filter: Query<any, any>,
|
|
500
|
+
projection: ProjectionType<TRawDocType> | null | undefined,
|
|
501
|
+
options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
|
|
502
|
+
): QueryWithHelpers<
|
|
503
|
+
TLeanResultType | null,
|
|
504
|
+
THydratedDocumentType,
|
|
505
|
+
TQueryHelpers,
|
|
506
|
+
TLeanResultType,
|
|
507
|
+
'findOne',
|
|
508
|
+
TInstanceMethods & TVirtuals
|
|
509
|
+
>;
|
|
512
510
|
findOne<ResultDoc = THydratedDocumentType>(
|
|
513
511
|
filter?: QueryFilter<TRawDocType>,
|
|
514
512
|
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
@@ -521,6 +519,18 @@ declare module 'mongoose' {
|
|
|
521
519
|
'findOne',
|
|
522
520
|
TInstanceMethods & TVirtuals
|
|
523
521
|
>;
|
|
522
|
+
findOne(
|
|
523
|
+
filter?: Query<any, any>,
|
|
524
|
+
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
525
|
+
options?: QueryOptions<TRawDocType> & mongodb.Abortable | null | undefined
|
|
526
|
+
): QueryWithHelpers<
|
|
527
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : THydratedDocumentType | null,
|
|
528
|
+
THydratedDocumentType,
|
|
529
|
+
TQueryHelpers,
|
|
530
|
+
TLeanResultType,
|
|
531
|
+
'findOne',
|
|
532
|
+
TInstanceMethods & TVirtuals
|
|
533
|
+
>;
|
|
524
534
|
|
|
525
535
|
/**
|
|
526
536
|
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
@@ -697,6 +707,22 @@ declare module 'mongoose' {
|
|
|
697
707
|
'distinct',
|
|
698
708
|
TInstanceMethods & TVirtuals
|
|
699
709
|
>;
|
|
710
|
+
distinct<DocKey extends string>(
|
|
711
|
+
field: DocKey,
|
|
712
|
+
filter?: Query<any, any>,
|
|
713
|
+
options?: QueryOptions<TRawDocType>
|
|
714
|
+
): QueryWithHelpers<
|
|
715
|
+
Array<
|
|
716
|
+
DocKey extends keyof WithLevel1NestedPaths<TRawDocType>
|
|
717
|
+
? WithoutUndefined<Unpacked<WithLevel1NestedPaths<TRawDocType>[DocKey]>>
|
|
718
|
+
: unknown
|
|
719
|
+
>,
|
|
720
|
+
THydratedDocumentType,
|
|
721
|
+
TQueryHelpers,
|
|
722
|
+
TLeanResultType,
|
|
723
|
+
'distinct',
|
|
724
|
+
TInstanceMethods & TVirtuals
|
|
725
|
+
>;
|
|
700
726
|
|
|
701
727
|
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
702
728
|
estimatedDocumentCount(options?: QueryOptions<TRawDocType>): QueryWithHelpers<
|
|
@@ -722,6 +748,16 @@ declare module 'mongoose' {
|
|
|
722
748
|
'findOne',
|
|
723
749
|
TInstanceMethods & TVirtuals
|
|
724
750
|
>;
|
|
751
|
+
exists(
|
|
752
|
+
filter: Query<any, any>
|
|
753
|
+
): QueryWithHelpers<
|
|
754
|
+
{ _id: InferId<TRawDocType> } | null,
|
|
755
|
+
THydratedDocumentType,
|
|
756
|
+
TQueryHelpers,
|
|
757
|
+
TLeanResultType,
|
|
758
|
+
'findOne',
|
|
759
|
+
TInstanceMethods & TVirtuals
|
|
760
|
+
>;
|
|
725
761
|
|
|
726
762
|
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
727
763
|
find<ResultDoc = THydratedDocumentType>(
|
|
@@ -736,6 +772,18 @@ declare module 'mongoose' {
|
|
|
736
772
|
'find',
|
|
737
773
|
TInstanceMethods & TVirtuals
|
|
738
774
|
>;
|
|
775
|
+
find(
|
|
776
|
+
filter: Query<any, any>,
|
|
777
|
+
projection: ProjectionType<TRawDocType> | null | undefined,
|
|
778
|
+
options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
|
|
779
|
+
): QueryWithHelpers<
|
|
780
|
+
GetLeanResultType<TRawDocType, TRawDocType[], 'find'>,
|
|
781
|
+
THydratedDocumentType,
|
|
782
|
+
TQueryHelpers,
|
|
783
|
+
TLeanResultType,
|
|
784
|
+
'find',
|
|
785
|
+
TInstanceMethods & TVirtuals
|
|
786
|
+
>;
|
|
739
787
|
find<ResultDoc = THydratedDocumentType>(
|
|
740
788
|
filter?: QueryFilter<TRawDocType>,
|
|
741
789
|
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
@@ -748,6 +796,18 @@ declare module 'mongoose' {
|
|
|
748
796
|
'find',
|
|
749
797
|
TInstanceMethods & TVirtuals
|
|
750
798
|
>;
|
|
799
|
+
find(
|
|
800
|
+
filter?: Query<any, any>,
|
|
801
|
+
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
802
|
+
options?: QueryOptions<TRawDocType> & mongodb.Abortable
|
|
803
|
+
): QueryWithHelpers<
|
|
804
|
+
THydratedDocumentType[],
|
|
805
|
+
THydratedDocumentType,
|
|
806
|
+
TQueryHelpers,
|
|
807
|
+
TLeanResultType,
|
|
808
|
+
'find',
|
|
809
|
+
TInstanceMethods & TVirtuals
|
|
810
|
+
>;
|
|
751
811
|
|
|
752
812
|
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
753
813
|
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
@@ -809,6 +869,18 @@ declare module 'mongoose' {
|
|
|
809
869
|
'findOneAndUpdate',
|
|
810
870
|
TInstanceMethods & TVirtuals
|
|
811
871
|
>;
|
|
872
|
+
findByIdAndUpdate(
|
|
873
|
+
filter: Query<any, any>,
|
|
874
|
+
update: UpdateQuery<TRawDocType>,
|
|
875
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
|
876
|
+
): QueryWithHelpers<
|
|
877
|
+
ModifyResult<TRawDocType>,
|
|
878
|
+
THydratedDocumentType,
|
|
879
|
+
TQueryHelpers,
|
|
880
|
+
TLeanResultType,
|
|
881
|
+
'findOneAndUpdate',
|
|
882
|
+
TInstanceMethods & TVirtuals
|
|
883
|
+
>;
|
|
812
884
|
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
813
885
|
id: mongodb.ObjectId | any,
|
|
814
886
|
update: UpdateQuery<TRawDocType>,
|
|
@@ -870,6 +942,17 @@ declare module 'mongoose' {
|
|
|
870
942
|
'findOneAndDelete',
|
|
871
943
|
TInstanceMethods & TVirtuals
|
|
872
944
|
>;
|
|
945
|
+
findOneAndDelete(
|
|
946
|
+
filter: Query<any, any>,
|
|
947
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
948
|
+
): QueryWithHelpers<
|
|
949
|
+
TLeanResultType | null,
|
|
950
|
+
THydratedDocumentType,
|
|
951
|
+
TQueryHelpers,
|
|
952
|
+
TLeanResultType,
|
|
953
|
+
'findOneAndDelete',
|
|
954
|
+
TInstanceMethods & TVirtuals
|
|
955
|
+
>;
|
|
873
956
|
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
874
957
|
filter: QueryFilter<TRawDocType>,
|
|
875
958
|
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
@@ -881,6 +964,17 @@ declare module 'mongoose' {
|
|
|
881
964
|
'findOneAndDelete',
|
|
882
965
|
TInstanceMethods & TVirtuals
|
|
883
966
|
>;
|
|
967
|
+
findOneAndDelete(
|
|
968
|
+
filter: Query<any, any>,
|
|
969
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
970
|
+
): QueryWithHelpers<
|
|
971
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TRawDocType> : ModifyResult<THydratedDocumentType>,
|
|
972
|
+
THydratedDocumentType,
|
|
973
|
+
TQueryHelpers,
|
|
974
|
+
TLeanResultType,
|
|
975
|
+
'findOneAndDelete',
|
|
976
|
+
TInstanceMethods & TVirtuals
|
|
977
|
+
>;
|
|
884
978
|
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
885
979
|
filter?: QueryFilter<TRawDocType> | null,
|
|
886
980
|
options?: QueryOptions<TRawDocType> | null
|
|
@@ -892,6 +986,17 @@ declare module 'mongoose' {
|
|
|
892
986
|
'findOneAndDelete',
|
|
893
987
|
TInstanceMethods & TVirtuals
|
|
894
988
|
>;
|
|
989
|
+
findOneAndDelete(
|
|
990
|
+
filter?: Query<any, any> | null,
|
|
991
|
+
options?: QueryOptions<TRawDocType> | null
|
|
992
|
+
): QueryWithHelpers<
|
|
993
|
+
HasLeanOption<TSchema> extends true ? TRawDocType | null : THydratedDocumentType | null,
|
|
994
|
+
THydratedDocumentType,
|
|
995
|
+
TQueryHelpers,
|
|
996
|
+
TLeanResultType,
|
|
997
|
+
'findOneAndDelete',
|
|
998
|
+
TInstanceMethods & TVirtuals
|
|
999
|
+
>;
|
|
895
1000
|
|
|
896
1001
|
/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
|
|
897
1002
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
@@ -906,6 +1011,18 @@ declare module 'mongoose' {
|
|
|
906
1011
|
'findOneAndReplace',
|
|
907
1012
|
TInstanceMethods & TVirtuals
|
|
908
1013
|
>;
|
|
1014
|
+
findOneAndReplace(
|
|
1015
|
+
filter: Query<any, any>,
|
|
1016
|
+
replacement: TRawDocType | AnyObject,
|
|
1017
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
1018
|
+
): QueryWithHelpers<
|
|
1019
|
+
TLeanResultType | null,
|
|
1020
|
+
THydratedDocumentType,
|
|
1021
|
+
TQueryHelpers,
|
|
1022
|
+
TLeanResultType,
|
|
1023
|
+
'findOneAndReplace',
|
|
1024
|
+
TInstanceMethods & TVirtuals
|
|
1025
|
+
>;
|
|
909
1026
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
910
1027
|
filter: QueryFilter<TRawDocType>,
|
|
911
1028
|
replacement: TRawDocType | AnyObject,
|
|
@@ -918,6 +1035,18 @@ declare module 'mongoose' {
|
|
|
918
1035
|
'findOneAndReplace',
|
|
919
1036
|
TInstanceMethods & TVirtuals
|
|
920
1037
|
>;
|
|
1038
|
+
findOneAndReplace(
|
|
1039
|
+
filter: Query<any, any>,
|
|
1040
|
+
replacement: TRawDocType | AnyObject,
|
|
1041
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
1042
|
+
): QueryWithHelpers<
|
|
1043
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<THydratedDocumentType>,
|
|
1044
|
+
THydratedDocumentType,
|
|
1045
|
+
TQueryHelpers,
|
|
1046
|
+
TLeanResultType,
|
|
1047
|
+
'findOneAndReplace',
|
|
1048
|
+
TInstanceMethods & TVirtuals
|
|
1049
|
+
>;
|
|
921
1050
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
922
1051
|
filter: QueryFilter<TRawDocType>,
|
|
923
1052
|
replacement: TRawDocType | AnyObject,
|
|
@@ -930,6 +1059,18 @@ declare module 'mongoose' {
|
|
|
930
1059
|
'findOneAndReplace',
|
|
931
1060
|
TInstanceMethods & TVirtuals
|
|
932
1061
|
>;
|
|
1062
|
+
findOneAndReplace(
|
|
1063
|
+
filter: Query<any, any>,
|
|
1064
|
+
replacement: TRawDocType | AnyObject,
|
|
1065
|
+
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
1066
|
+
): QueryWithHelpers<
|
|
1067
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType : THydratedDocumentType,
|
|
1068
|
+
THydratedDocumentType,
|
|
1069
|
+
TQueryHelpers,
|
|
1070
|
+
TLeanResultType,
|
|
1071
|
+
'findOneAndReplace',
|
|
1072
|
+
TInstanceMethods & TVirtuals
|
|
1073
|
+
>;
|
|
933
1074
|
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
934
1075
|
filter?: QueryFilter<TRawDocType>,
|
|
935
1076
|
replacement?: TRawDocType | AnyObject,
|
|
@@ -942,6 +1083,18 @@ declare module 'mongoose' {
|
|
|
942
1083
|
'findOneAndReplace',
|
|
943
1084
|
TInstanceMethods & TVirtuals
|
|
944
1085
|
>;
|
|
1086
|
+
findOneAndReplace(
|
|
1087
|
+
filter?: Query<any, any>,
|
|
1088
|
+
replacement?: TRawDocType | AnyObject,
|
|
1089
|
+
options?: QueryOptions<TRawDocType> | null
|
|
1090
|
+
): QueryWithHelpers<
|
|
1091
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : THydratedDocumentType | null,
|
|
1092
|
+
THydratedDocumentType,
|
|
1093
|
+
TQueryHelpers,
|
|
1094
|
+
TLeanResultType,
|
|
1095
|
+
'findOneAndReplace',
|
|
1096
|
+
TInstanceMethods & TVirtuals
|
|
1097
|
+
>;
|
|
945
1098
|
|
|
946
1099
|
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
947
1100
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
@@ -956,6 +1109,18 @@ declare module 'mongoose' {
|
|
|
956
1109
|
'findOneAndUpdate',
|
|
957
1110
|
TInstanceMethods & TVirtuals
|
|
958
1111
|
>;
|
|
1112
|
+
findOneAndUpdate(
|
|
1113
|
+
filter: Query<any, any>,
|
|
1114
|
+
update: UpdateQuery<TRawDocType>,
|
|
1115
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
|
1116
|
+
): QueryWithHelpers<
|
|
1117
|
+
ModifyResult<TRawDocType>,
|
|
1118
|
+
THydratedDocumentType,
|
|
1119
|
+
TQueryHelpers,
|
|
1120
|
+
TLeanResultType,
|
|
1121
|
+
'findOneAndUpdate',
|
|
1122
|
+
TInstanceMethods & TVirtuals
|
|
1123
|
+
>;
|
|
959
1124
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
960
1125
|
filter: QueryFilter<TRawDocType>,
|
|
961
1126
|
update: UpdateQuery<TRawDocType>,
|
|
@@ -968,6 +1133,18 @@ declare module 'mongoose' {
|
|
|
968
1133
|
'findOneAndUpdate',
|
|
969
1134
|
TInstanceMethods & TVirtuals
|
|
970
1135
|
>;
|
|
1136
|
+
findOneAndUpdate(
|
|
1137
|
+
filter: Query<any, any>,
|
|
1138
|
+
update: UpdateQuery<TRawDocType>,
|
|
1139
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
1140
|
+
): QueryWithHelpers<
|
|
1141
|
+
GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndUpdate'> | null,
|
|
1142
|
+
THydratedDocumentType,
|
|
1143
|
+
TQueryHelpers,
|
|
1144
|
+
TLeanResultType,
|
|
1145
|
+
'findOneAndUpdate',
|
|
1146
|
+
TInstanceMethods & TVirtuals
|
|
1147
|
+
>;
|
|
971
1148
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
972
1149
|
filter: QueryFilter<TRawDocType>,
|
|
973
1150
|
update: UpdateQuery<TRawDocType>,
|
|
@@ -980,6 +1157,18 @@ declare module 'mongoose' {
|
|
|
980
1157
|
'findOneAndUpdate',
|
|
981
1158
|
TInstanceMethods & TVirtuals
|
|
982
1159
|
>;
|
|
1160
|
+
findOneAndUpdate(
|
|
1161
|
+
filter: Query<any, any>,
|
|
1162
|
+
update: UpdateQuery<TRawDocType>,
|
|
1163
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
1164
|
+
): QueryWithHelpers<
|
|
1165
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<THydratedDocumentType>,
|
|
1166
|
+
THydratedDocumentType,
|
|
1167
|
+
TQueryHelpers,
|
|
1168
|
+
TLeanResultType,
|
|
1169
|
+
'findOneAndUpdate',
|
|
1170
|
+
TInstanceMethods & TVirtuals
|
|
1171
|
+
>;
|
|
983
1172
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
984
1173
|
filter: QueryFilter<TRawDocType>,
|
|
985
1174
|
update: UpdateQuery<TRawDocType>,
|
|
@@ -992,6 +1181,18 @@ declare module 'mongoose' {
|
|
|
992
1181
|
'findOneAndUpdate',
|
|
993
1182
|
TInstanceMethods & TVirtuals
|
|
994
1183
|
>;
|
|
1184
|
+
findOneAndUpdate(
|
|
1185
|
+
filter: Query<any, any>,
|
|
1186
|
+
update: UpdateQuery<TRawDocType>,
|
|
1187
|
+
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
1188
|
+
): QueryWithHelpers<
|
|
1189
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType : THydratedDocumentType,
|
|
1190
|
+
THydratedDocumentType,
|
|
1191
|
+
TQueryHelpers,
|
|
1192
|
+
TLeanResultType,
|
|
1193
|
+
'findOneAndUpdate',
|
|
1194
|
+
TInstanceMethods & TVirtuals
|
|
1195
|
+
>;
|
|
995
1196
|
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
996
1197
|
filter?: QueryFilter<TRawDocType>,
|
|
997
1198
|
update?: UpdateQuery<TRawDocType>,
|
|
@@ -1004,6 +1205,18 @@ declare module 'mongoose' {
|
|
|
1004
1205
|
'findOneAndUpdate',
|
|
1005
1206
|
TInstanceMethods & TVirtuals
|
|
1006
1207
|
>;
|
|
1208
|
+
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
1209
|
+
filter?: Query<any, any>,
|
|
1210
|
+
update?: UpdateQuery<TRawDocType>,
|
|
1211
|
+
options?: QueryOptions<TRawDocType> | null
|
|
1212
|
+
): QueryWithHelpers<
|
|
1213
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
1214
|
+
ResultDoc,
|
|
1215
|
+
TQueryHelpers,
|
|
1216
|
+
TLeanResultType,
|
|
1217
|
+
'findOneAndUpdate',
|
|
1218
|
+
TInstanceMethods & TVirtuals
|
|
1219
|
+
>;
|
|
1007
1220
|
|
|
1008
1221
|
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
1009
1222
|
replaceOne<ResultDoc = THydratedDocumentType>(
|
|
@@ -1011,12 +1224,17 @@ declare module 'mongoose' {
|
|
|
1011
1224
|
replacement?: TRawDocType | AnyObject,
|
|
1012
1225
|
options?: (mongodb.ReplaceOptions & QueryOptions<TRawDocType>) | null
|
|
1013
1226
|
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TLeanResultType, 'replaceOne', TInstanceMethods & TVirtuals>;
|
|
1227
|
+
replaceOne<ResultDoc = THydratedDocumentType>(
|
|
1228
|
+
filter?: Query<any, any>,
|
|
1229
|
+
replacement?: TRawDocType | AnyObject,
|
|
1230
|
+
options?: (mongodb.ReplaceOptions & QueryOptions<TRawDocType>) | null
|
|
1231
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TLeanResultType, 'replaceOne', TInstanceMethods & TVirtuals>;
|
|
1014
1232
|
|
|
1015
1233
|
/** Apply changes made to this model's schema after this model was compiled. */
|
|
1016
1234
|
recompileSchema(): void;
|
|
1017
1235
|
|
|
1018
1236
|
/** Schema the model uses. */
|
|
1019
|
-
schema:
|
|
1237
|
+
schema: TSchema;
|
|
1020
1238
|
|
|
1021
1239
|
/** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */
|
|
1022
1240
|
updateMany(
|
|
@@ -1024,6 +1242,11 @@ declare module 'mongoose' {
|
|
|
1024
1242
|
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1025
1243
|
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1026
1244
|
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateMany', TInstanceMethods & TVirtuals>;
|
|
1245
|
+
updateMany(
|
|
1246
|
+
filter: Query<any, any>,
|
|
1247
|
+
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1248
|
+
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1249
|
+
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateMany', TInstanceMethods & TVirtuals>;
|
|
1027
1250
|
|
|
1028
1251
|
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
1029
1252
|
updateOne(
|
|
@@ -1031,6 +1254,11 @@ declare module 'mongoose' {
|
|
|
1031
1254
|
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1032
1255
|
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1033
1256
|
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateOne', TInstanceMethods & TVirtuals>;
|
|
1257
|
+
updateOne(
|
|
1258
|
+
filter: Query<any, any>,
|
|
1259
|
+
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1260
|
+
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1261
|
+
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateOne', TInstanceMethods & TVirtuals>;
|
|
1034
1262
|
|
|
1035
1263
|
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
1036
1264
|
where<ResultDoc = THydratedDocumentType>(
|