mongoose 6.2.11 → 6.3.0
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/CHANGELOG.md +11 -0
- package/dist/browser.umd.js +2 -1704
- package/lib/aggregate.js +4 -3
- package/lib/cursor/ChangeStream.js +42 -2
- package/lib/cursor/QueryCursor.js +2 -0
- package/lib/error/eachAsyncMultiError.js +41 -0
- package/lib/helpers/cursor/eachAsync.js +44 -12
- package/lib/helpers/model/discriminator.js +1 -3
- package/lib/helpers/query/applyGlobalOption.js +29 -0
- package/lib/index.js +10 -3
- package/lib/model.js +1 -2
- package/lib/query.js +21 -3
- package/lib/schema.js +114 -1
- package/lib/validoptions.js +1 -0
- package/package.json +10 -6
- package/tools/repl.js +2 -1
- package/types/cursor.d.ts +10 -4
- package/types/index.d.ts +181 -57
- package/types/mongooseoptions.d.ts +10 -4
- package/lib/helpers/query/applyGlobalMaxTimeMS.js +0 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.3.0",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"bson": "^4.2.2",
|
|
23
23
|
"kareem": "2.3.5",
|
|
24
|
-
"mongodb": "4.
|
|
24
|
+
"mongodb": "4.5.0",
|
|
25
25
|
"mpath": "0.8.4",
|
|
26
26
|
"mquery": "4.0.2",
|
|
27
27
|
"ms": "2.1.3",
|
|
@@ -35,11 +35,13 @@
|
|
|
35
35
|
"acquit": "1.2.1",
|
|
36
36
|
"acquit-ignore": "0.2.0",
|
|
37
37
|
"acquit-require": "0.1.1",
|
|
38
|
+
"assert-browserify": "npm:assert@^2.0.0",
|
|
38
39
|
"axios": "0.26.1",
|
|
39
40
|
"babel-loader": "8.2.4",
|
|
40
41
|
"benchmark": "2.1.4",
|
|
41
42
|
"bluebird": "3.7.2",
|
|
42
43
|
"cheerio": "1.0.0-rc.10",
|
|
44
|
+
"crypto-browserify": "3.12.0",
|
|
43
45
|
"dox": "0.3.1",
|
|
44
46
|
"eslint": "8.12.0",
|
|
45
47
|
"eslint-plugin-mocha-no-only": "1.1.1",
|
|
@@ -49,15 +51,17 @@
|
|
|
49
51
|
"marked": "4.0.12",
|
|
50
52
|
"mocha": "9.2.2",
|
|
51
53
|
"moment": "2.x",
|
|
52
|
-
"mongodb-memory-server": "
|
|
53
|
-
"nyc": "
|
|
54
|
+
"mongodb-memory-server": "8.3.0",
|
|
55
|
+
"nyc": "15.1.0",
|
|
54
56
|
"pug": "3.0.2",
|
|
55
57
|
"q": "1.5.1",
|
|
56
58
|
"serve-handler": "6.1.3",
|
|
57
|
-
"
|
|
59
|
+
"sinon": "13.0.0",
|
|
60
|
+
"stream-browserify": "3.0.0",
|
|
61
|
+
"tsd": "0.19.1",
|
|
58
62
|
"typescript": "4.6.3",
|
|
59
63
|
"uuid": "8.3.2",
|
|
60
|
-
"webpack": "
|
|
64
|
+
"webpack": "5.70.0"
|
|
61
65
|
},
|
|
62
66
|
"directories": {
|
|
63
67
|
"lib": "./lib/mongoose"
|
package/tools/repl.js
CHANGED
|
@@ -17,7 +17,8 @@ async function run() {
|
|
|
17
17
|
// Set the expiry job in MongoDB to run every second
|
|
18
18
|
{
|
|
19
19
|
port: 27017,
|
|
20
|
-
args: ['--setParameter', 'ttlMonitorSleepSecs=1']
|
|
20
|
+
args: ['--setParameter', 'ttlMonitorSleepSecs=1']
|
|
21
|
+
}
|
|
21
22
|
],
|
|
22
23
|
dbName: 'mongoose_test',
|
|
23
24
|
replSet: {
|
package/types/cursor.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import stream = require('stream');
|
|
|
3
3
|
declare module 'mongoose' {
|
|
4
4
|
type CursorFlag = 'tailable' | 'oplogReplay' | 'noCursorTimeout' | 'awaitData' | 'partial';
|
|
5
5
|
|
|
6
|
+
interface EachAsyncOptions {
|
|
7
|
+
parallel?: number;
|
|
8
|
+
batchSize?: number;
|
|
9
|
+
continueOnError?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
class Cursor<DocType = any, Options = never> extends stream.Readable {
|
|
7
13
|
[Symbol.asyncIterator](): AsyncIterableIterator<DocType>;
|
|
8
14
|
|
|
@@ -25,10 +31,10 @@ declare module 'mongoose' {
|
|
|
25
31
|
* will wait for the promise to resolve before iterating on to the next one.
|
|
26
32
|
* Returns a promise that resolves when done.
|
|
27
33
|
*/
|
|
28
|
-
eachAsync(fn: (doc: DocType[]) => any, options:
|
|
29
|
-
eachAsync(fn: (doc: DocType) => any, options:
|
|
30
|
-
eachAsync(fn: (doc: DocType[]) => any, options:
|
|
31
|
-
eachAsync(fn: (doc: DocType) => any, options?:
|
|
34
|
+
eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }, callback: CallbackWithoutResult): void;
|
|
35
|
+
eachAsync(fn: (doc: DocType) => any, options: EachAsyncOptions, callback: CallbackWithoutResult): void;
|
|
36
|
+
eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }): Promise<void>;
|
|
37
|
+
eachAsync(fn: (doc: DocType) => any, options?: EachAsyncOptions): Promise<void>;
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* Registers a transform function which subsequently maps documents retrieved
|
package/types/index.d.ts
CHANGED
|
@@ -299,7 +299,7 @@ declare module 'mongoose' {
|
|
|
299
299
|
|
|
300
300
|
/** Creates a `countDocuments` query: counts the number of documents that match `filter`. */
|
|
301
301
|
countDocuments(callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
302
|
-
countDocuments(filter: FilterQuery<T>, options?: QueryOptions
|
|
302
|
+
countDocuments(filter: FilterQuery<T>, options?: QueryOptions<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
303
303
|
|
|
304
304
|
/** Creates a new document or documents */
|
|
305
305
|
create(docs: (AnyKeys<T> | AnyObject)[], options?: SaveOptions): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
@@ -335,7 +335,7 @@ declare module 'mongoose' {
|
|
|
335
335
|
* Behaves like `remove()`, but deletes all documents that match `conditions`
|
|
336
336
|
* regardless of the `single` option.
|
|
337
337
|
*/
|
|
338
|
-
deleteMany(filter?: FilterQuery<T>, options?: QueryOptions
|
|
338
|
+
deleteMany(filter?: FilterQuery<T>, options?: QueryOptions<T>, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
339
339
|
deleteMany(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
340
340
|
deleteMany(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
341
341
|
|
|
@@ -344,7 +344,7 @@ declare module 'mongoose' {
|
|
|
344
344
|
* Behaves like `remove()`, but deletes at most one document regardless of the
|
|
345
345
|
* `single` option.
|
|
346
346
|
*/
|
|
347
|
-
deleteOne(filter?: FilterQuery<T>, options?: QueryOptions
|
|
347
|
+
deleteOne(filter?: FilterQuery<T>, options?: QueryOptions<T>, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
348
348
|
deleteOne(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
349
349
|
deleteOne(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
350
350
|
|
|
@@ -366,10 +366,34 @@ declare module 'mongoose' {
|
|
|
366
366
|
* equivalent to `findOne({ _id: id })`. If you want to query by a document's
|
|
367
367
|
* `_id`, use `findById()` instead of `findOne()`.
|
|
368
368
|
*/
|
|
369
|
-
findById<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
369
|
+
findById<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
370
|
+
id: any,
|
|
371
|
+
projection?: ProjectionType<T> | null,
|
|
372
|
+
options?: QueryOptions<T> | null,
|
|
373
|
+
callback?: Callback<ResultDoc | null>
|
|
374
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
375
|
+
findById<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
376
|
+
id: any,
|
|
377
|
+
projection?: ProjectionType<T> | null,
|
|
378
|
+
callback?: Callback<ResultDoc | null>
|
|
379
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
370
380
|
|
|
371
381
|
/** Finds one document. */
|
|
372
|
-
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
382
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
383
|
+
filter?: FilterQuery<T>,
|
|
384
|
+
projection?: ProjectionType<T> | null,
|
|
385
|
+
options?: QueryOptions<T> | null,
|
|
386
|
+
callback?: Callback<ResultDoc | null>
|
|
387
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
388
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
389
|
+
filter?: FilterQuery<T>,
|
|
390
|
+
projection?: ProjectionType<T> | null,
|
|
391
|
+
callback?: Callback<ResultDoc | null>
|
|
392
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
393
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
394
|
+
filter?: FilterQuery<T>,
|
|
395
|
+
callback?: Callback<ResultDoc | null>
|
|
396
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
373
397
|
|
|
374
398
|
/**
|
|
375
399
|
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
@@ -458,7 +482,7 @@ declare module 'mongoose' {
|
|
|
458
482
|
distinct<ReturnType = any>(field: string, filter?: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<Array<ReturnType>, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
459
483
|
|
|
460
484
|
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
461
|
-
estimatedDocumentCount(options?: QueryOptions
|
|
485
|
+
estimatedDocumentCount(options?: QueryOptions<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
462
486
|
|
|
463
487
|
/**
|
|
464
488
|
* Returns a document with its `_id` if at least one document exists in the database that matches
|
|
@@ -469,37 +493,61 @@ declare module 'mongoose' {
|
|
|
469
493
|
|
|
470
494
|
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
471
495
|
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(callback?: Callback<ResultDoc[]>): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
496
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
497
|
+
filter: FilterQuery<T>,
|
|
498
|
+
projection?: ProjectionType<T> | null,
|
|
499
|
+
callback?: Callback<ResultDoc[]>
|
|
500
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
472
501
|
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, callback?: Callback<ResultDoc[]>): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
473
|
-
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, projection?:
|
|
502
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, projection?: ProjectionType<T> | null, options?: QueryOptions<T> | null, callback?: Callback<ResultDoc[]>): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
474
503
|
|
|
475
504
|
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
476
|
-
findByIdAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
505
|
+
findByIdAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
477
506
|
|
|
478
507
|
/** Creates a `findByIdAndRemove` query, filtering by the given `_id`. */
|
|
479
|
-
findByIdAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
508
|
+
findByIdAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
480
509
|
|
|
481
510
|
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
482
|
-
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions & { rawResult: true }, callback?: (err: CallbackError, doc: any, res: any) => void): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
483
|
-
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
484
|
-
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, update?: UpdateQuery<T>, options?: QueryOptions | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
511
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions<T> & { rawResult: true }, callback?: (err: CallbackError, doc: any, res: any) => void): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
512
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
513
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, update?: UpdateQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
485
514
|
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, callback: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
486
515
|
|
|
487
516
|
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
488
|
-
findOneAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
517
|
+
findOneAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
489
518
|
|
|
490
519
|
/** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */
|
|
491
|
-
findOneAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
520
|
+
findOneAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
492
521
|
|
|
493
522
|
/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
|
|
494
|
-
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, replacement: T | AnyObject, options: QueryOptions & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
495
|
-
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, replacement?: T | AnyObject, options?: QueryOptions | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
523
|
+
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, replacement: T | AnyObject, options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
524
|
+
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, replacement?: T | AnyObject, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
496
525
|
|
|
497
526
|
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
498
|
-
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
527
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
528
|
+
filter: FilterQuery<T>,
|
|
529
|
+
update: UpdateQuery<T>,
|
|
530
|
+
options: QueryOptions<T> & { rawResult: true },
|
|
531
|
+
callback?: (err: CallbackError, doc: any, res: any) => void
|
|
532
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
533
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
534
|
+
filter: FilterQuery<T>,
|
|
535
|
+
update: UpdateQuery<T>,
|
|
536
|
+
options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc,
|
|
537
|
+
callback?: (err: CallbackError, doc: ResultDoc, res: any) => void
|
|
538
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
539
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
540
|
+
filter?: FilterQuery<T>,
|
|
541
|
+
update?: UpdateQuery<T>,
|
|
542
|
+
options?: QueryOptions<T> | null,
|
|
543
|
+
callback?: (err: CallbackError, doc: T | null, res: any) => void
|
|
544
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
545
|
+
|
|
546
|
+
geoSearch<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
547
|
+
filter?: FilterQuery<T>,
|
|
548
|
+
options?: GeoSearchOptions,
|
|
549
|
+
callback?: Callback<Array<ResultDoc>>
|
|
550
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
503
551
|
|
|
504
552
|
/** Executes a mapReduce command. */
|
|
505
553
|
mapReduce<Key, Value>(
|
|
@@ -510,8 +558,18 @@ declare module 'mongoose' {
|
|
|
510
558
|
remove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: any, callback?: CallbackWithoutResult): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
|
|
511
559
|
|
|
512
560
|
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
513
|
-
replaceOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
514
|
-
|
|
561
|
+
replaceOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
562
|
+
filter?: FilterQuery<T>,
|
|
563
|
+
replacement?: T | AnyObject,
|
|
564
|
+
options?: QueryOptions<T> | null,
|
|
565
|
+
callback?: Callback
|
|
566
|
+
): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
|
|
567
|
+
replaceOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
568
|
+
filter?: FilterQuery<T>,
|
|
569
|
+
replacement?: T | AnyObject,
|
|
570
|
+
options?: QueryOptions<T> | null,
|
|
571
|
+
callback?: Callback
|
|
572
|
+
): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
|
|
515
573
|
|
|
516
574
|
/** Schema the model uses. */
|
|
517
575
|
schema: Schema<T>;
|
|
@@ -520,13 +578,28 @@ declare module 'mongoose' {
|
|
|
520
578
|
* @deprecated use `updateOne` or `updateMany` instead.
|
|
521
579
|
* Creates a `update` query: updates one or many documents that match `filter` with `update`, based on the `multi` option.
|
|
522
580
|
*/
|
|
523
|
-
update<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
581
|
+
update<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
582
|
+
filter?: FilterQuery<T>,
|
|
583
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
584
|
+
options?: QueryOptions<T> | null,
|
|
585
|
+
callback?: Callback
|
|
586
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
524
587
|
|
|
525
588
|
/** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */
|
|
526
|
-
updateMany<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
589
|
+
updateMany<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
590
|
+
filter?: FilterQuery<T>,
|
|
591
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
592
|
+
options?: QueryOptions<T> | null,
|
|
593
|
+
callback?: Callback
|
|
594
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
527
595
|
|
|
528
596
|
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
529
|
-
updateOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
597
|
+
updateOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
598
|
+
filter?: FilterQuery<T>,
|
|
599
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
600
|
+
options?: QueryOptions<T> | null,
|
|
601
|
+
callback?: Callback
|
|
602
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
530
603
|
|
|
531
604
|
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
532
605
|
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(path: string, val?: any): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
@@ -536,7 +609,7 @@ declare module 'mongoose' {
|
|
|
536
609
|
|
|
537
610
|
type UpdateWriteOpResult = mongodb.UpdateResult;
|
|
538
611
|
|
|
539
|
-
interface QueryOptions {
|
|
612
|
+
interface QueryOptions<DocType = unknown> {
|
|
540
613
|
arrayFilters?: { [key: string]: any }[];
|
|
541
614
|
batchSize?: number;
|
|
542
615
|
collation?: mongodb.CollationOptions;
|
|
@@ -563,7 +636,7 @@ declare module 'mongoose' {
|
|
|
563
636
|
overwrite?: boolean;
|
|
564
637
|
overwriteDiscriminatorKey?: boolean;
|
|
565
638
|
populate?: string | string[] | PopulateOptions | PopulateOptions[];
|
|
566
|
-
projection?:
|
|
639
|
+
projection?: ProjectionType<DocType>;
|
|
567
640
|
/**
|
|
568
641
|
* if true, returns the raw result from the MongoDB driver
|
|
569
642
|
*/
|
|
@@ -611,7 +684,7 @@ declare module 'mongoose' {
|
|
|
611
684
|
[other: string]: any;
|
|
612
685
|
}
|
|
613
686
|
|
|
614
|
-
type MongooseQueryOptions = Pick<QueryOptions
|
|
687
|
+
type MongooseQueryOptions<DocType = unknown> = Pick<QueryOptions<DocType>, 'populate' | 'lean' | 'strict' | 'sanitizeProjection' | 'sanitizeFilter'>;
|
|
615
688
|
|
|
616
689
|
interface SaveOptions {
|
|
617
690
|
checkKeys?: boolean;
|
|
@@ -780,6 +853,9 @@ declare module 'mongoose' {
|
|
|
780
853
|
*/
|
|
781
854
|
childSchemas: { schema: Schema, model: any }[];
|
|
782
855
|
|
|
856
|
+
/** Removes all indexes on this schema */
|
|
857
|
+
clearIndexes(): this;
|
|
858
|
+
|
|
783
859
|
/** Returns a copy of this schema */
|
|
784
860
|
clone<T = this>(): T;
|
|
785
861
|
|
|
@@ -879,6 +955,9 @@ declare module 'mongoose' {
|
|
|
879
955
|
/** Removes the given `path` (or [`paths`]). */
|
|
880
956
|
remove(paths: string | Array<string>): this;
|
|
881
957
|
|
|
958
|
+
/** Removes index by name or index spec */
|
|
959
|
+
remove(index: string | AnyObject): this;
|
|
960
|
+
|
|
882
961
|
/** Returns an Array of path strings that are required by this schema. */
|
|
883
962
|
requiredPaths(invalidate?: boolean): string[];
|
|
884
963
|
|
|
@@ -893,7 +972,10 @@ declare module 'mongoose' {
|
|
|
893
972
|
statics: { [name: string]: (this: M, ...args: any[]) => any };
|
|
894
973
|
|
|
895
974
|
/** Creates a virtual type with the given name. */
|
|
896
|
-
virtual<T = HydratedDocument<DocType, TInstanceMethods>>(
|
|
975
|
+
virtual<T = HydratedDocument<DocType, TInstanceMethods>>(
|
|
976
|
+
name: string,
|
|
977
|
+
options?: VirtualTypeOptions<T, DocType>
|
|
978
|
+
): VirtualType;
|
|
897
979
|
|
|
898
980
|
/** Object of currently defined virtuals on this schema */
|
|
899
981
|
virtuals: any;
|
|
@@ -1164,7 +1246,7 @@ declare module 'mongoose' {
|
|
|
1164
1246
|
|
|
1165
1247
|
type InferId<T> = T extends { _id?: any } ? T['_id'] : Types.ObjectId;
|
|
1166
1248
|
|
|
1167
|
-
interface VirtualTypeOptions<HydratedDocType = Document> {
|
|
1249
|
+
interface VirtualTypeOptions<HydratedDocType = Document, DocType = unknown> {
|
|
1168
1250
|
/** If `ref` is not nullish, this becomes a populated virtual. */
|
|
1169
1251
|
ref?: string | Function;
|
|
1170
1252
|
|
|
@@ -1208,7 +1290,7 @@ declare module 'mongoose' {
|
|
|
1208
1290
|
perDocumentLimit?: number;
|
|
1209
1291
|
|
|
1210
1292
|
/** Additional options like `limit` and `lean`. */
|
|
1211
|
-
options?: QueryOptions & { match?: AnyObject };
|
|
1293
|
+
options?: QueryOptions<DocType> & { match?: AnyObject };
|
|
1212
1294
|
|
|
1213
1295
|
/** Additional options for plugins */
|
|
1214
1296
|
[extra: string]: any;
|
|
@@ -1488,7 +1570,7 @@ declare module 'mongoose' {
|
|
|
1488
1570
|
type ProjectionFields<DocType> = { [Key in keyof Omit<LeanDocument<DocType>, '__v'>]?: any } & Record<string, any>;
|
|
1489
1571
|
|
|
1490
1572
|
class Query<ResultType, DocType, THelpers = {}, RawDocType = DocType> {
|
|
1491
|
-
_mongooseOptions: MongooseQueryOptions
|
|
1573
|
+
_mongooseOptions: MongooseQueryOptions<DocType>;
|
|
1492
1574
|
|
|
1493
1575
|
/**
|
|
1494
1576
|
* Returns a wrapper around a [mongodb driver cursor](http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html).
|
|
@@ -1557,20 +1639,24 @@ declare module 'mongoose' {
|
|
|
1557
1639
|
|
|
1558
1640
|
/** Specifies this query as a `countDocuments` query. */
|
|
1559
1641
|
countDocuments(callback?: Callback<number>): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
1560
|
-
countDocuments(
|
|
1642
|
+
countDocuments(
|
|
1643
|
+
criteria: FilterQuery<DocType>,
|
|
1644
|
+
options?: QueryOptions<DocType>,
|
|
1645
|
+
callback?: Callback<number>
|
|
1646
|
+
): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
1561
1647
|
|
|
1562
1648
|
/**
|
|
1563
1649
|
* Returns a wrapper around a [mongodb driver cursor](http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html).
|
|
1564
1650
|
* A QueryCursor exposes a Streams3 interface, as well as a `.next()` function.
|
|
1565
1651
|
*/
|
|
1566
|
-
cursor(options?: QueryOptions): Cursor<DocType, QueryOptions
|
|
1652
|
+
cursor(options?: QueryOptions<DocType>): Cursor<DocType, QueryOptions<DocType>>;
|
|
1567
1653
|
|
|
1568
1654
|
/**
|
|
1569
1655
|
* Declare and/or execute this query as a `deleteMany()` operation. Works like
|
|
1570
1656
|
* remove, except it deletes _every_ document that matches `filter` in the
|
|
1571
1657
|
* collection, regardless of the value of `single`.
|
|
1572
1658
|
*/
|
|
1573
|
-
deleteMany(filter?: FilterQuery<DocType>, options?: QueryOptions
|
|
1659
|
+
deleteMany(filter?: FilterQuery<DocType>, options?: QueryOptions<DocType>, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1574
1660
|
deleteMany(filter: FilterQuery<DocType>, callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1575
1661
|
deleteMany(callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1576
1662
|
|
|
@@ -1579,7 +1665,7 @@ declare module 'mongoose' {
|
|
|
1579
1665
|
* remove, except it deletes at most one document regardless of the `single`
|
|
1580
1666
|
* option.
|
|
1581
1667
|
*/
|
|
1582
|
-
deleteOne(filter?: FilterQuery<DocType>, options?: QueryOptions
|
|
1668
|
+
deleteOne(filter?: FilterQuery<DocType>, options?: QueryOptions<DocType>, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1583
1669
|
deleteOne(filter: FilterQuery<DocType>, callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1584
1670
|
deleteOne(callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1585
1671
|
|
|
@@ -1601,7 +1687,7 @@ declare module 'mongoose' {
|
|
|
1601
1687
|
equals(val: any): this;
|
|
1602
1688
|
|
|
1603
1689
|
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
1604
|
-
estimatedDocumentCount(options?: QueryOptions
|
|
1690
|
+
estimatedDocumentCount(options?: QueryOptions<DocType>, callback?: Callback<number>): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
1605
1691
|
|
|
1606
1692
|
/** Specifies a `$exists` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
1607
1693
|
exists(val: boolean): this;
|
|
@@ -1617,45 +1703,80 @@ declare module 'mongoose' {
|
|
|
1617
1703
|
|
|
1618
1704
|
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
1619
1705
|
find(callback?: Callback<DocType[]>): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType>;
|
|
1620
|
-
find(
|
|
1621
|
-
|
|
1706
|
+
find(
|
|
1707
|
+
filter: FilterQuery<DocType>,
|
|
1708
|
+
callback?: Callback<DocType[]>
|
|
1709
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType>;
|
|
1710
|
+
find(
|
|
1711
|
+
filter: FilterQuery<DocType>,
|
|
1712
|
+
projection?: ProjectionType<DocType> | null,
|
|
1713
|
+
callback?: Callback<DocType[]>
|
|
1714
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType>;
|
|
1715
|
+
find(
|
|
1716
|
+
filter: FilterQuery<DocType>,
|
|
1717
|
+
projection?: ProjectionType<DocType> | null,
|
|
1718
|
+
options?: QueryOptions<DocType> | null,
|
|
1719
|
+
callback?: Callback<DocType[]>
|
|
1720
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType>;
|
|
1622
1721
|
|
|
1623
1722
|
/** Declares the query a findOne operation. When executed, the first found document is passed to the callback. */
|
|
1624
|
-
findOne(
|
|
1723
|
+
findOne(
|
|
1724
|
+
filter?: FilterQuery<DocType>,
|
|
1725
|
+
projection?: ProjectionType<DocType> | null,
|
|
1726
|
+
options?: QueryOptions<DocType> | null,
|
|
1727
|
+
callback?: Callback<DocType | null>
|
|
1728
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1729
|
+
findOne(
|
|
1730
|
+
filter?: FilterQuery<DocType>,
|
|
1731
|
+
projection?: ProjectionType<DocType> | null,
|
|
1732
|
+
callback?: Callback<DocType | null>
|
|
1733
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1734
|
+
findOne(
|
|
1735
|
+
filter?: FilterQuery<DocType>,
|
|
1736
|
+
callback?: Callback<DocType | null>
|
|
1737
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1625
1738
|
|
|
1626
1739
|
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
1627
|
-
findOneAndDelete(
|
|
1740
|
+
findOneAndDelete(
|
|
1741
|
+
filter?: FilterQuery<DocType>,
|
|
1742
|
+
options?: QueryOptions<DocType> | null,
|
|
1743
|
+
callback?: (err: CallbackError, doc: DocType | null, res: any) => void
|
|
1744
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1628
1745
|
|
|
1629
1746
|
/** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */
|
|
1630
|
-
findOneAndRemove(
|
|
1747
|
+
findOneAndRemove(
|
|
1748
|
+
filter?: FilterQuery<DocType>,
|
|
1749
|
+
options?: QueryOptions<DocType> | null,
|
|
1750
|
+
callback?: (err: CallbackError, doc: DocType | null, res: any) => void
|
|
1751
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1631
1752
|
|
|
1632
1753
|
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
1633
1754
|
findOneAndUpdate(
|
|
1634
1755
|
filter: FilterQuery<DocType>,
|
|
1635
1756
|
update: UpdateQuery<DocType>,
|
|
1636
|
-
options: QueryOptions & { rawResult: true },
|
|
1757
|
+
options: QueryOptions<DocType> & { rawResult: true },
|
|
1637
1758
|
callback?: (err: CallbackError, doc: DocType | null, res: ModifyResult<DocType>) => void
|
|
1638
1759
|
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType>;
|
|
1639
1760
|
findOneAndUpdate(
|
|
1640
1761
|
filter: FilterQuery<DocType>,
|
|
1641
1762
|
update: UpdateQuery<DocType>,
|
|
1642
|
-
options: QueryOptions & { upsert: true } & ReturnsNewDoc,
|
|
1763
|
+
options: QueryOptions<DocType> & { upsert: true } & ReturnsNewDoc,
|
|
1643
1764
|
callback?: (err: CallbackError, doc: DocType, res: ModifyResult<DocType>) => void
|
|
1644
1765
|
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType>;
|
|
1645
1766
|
findOneAndUpdate(
|
|
1646
1767
|
filter?: FilterQuery<DocType>,
|
|
1647
1768
|
update?: UpdateQuery<DocType>,
|
|
1648
|
-
options?: QueryOptions | null,
|
|
1769
|
+
options?: QueryOptions<DocType> | null,
|
|
1649
1770
|
callback?: (err: CallbackError, doc: DocType | null, res: ModifyResult<DocType>) => void
|
|
1650
1771
|
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1651
1772
|
|
|
1652
1773
|
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
1653
|
-
findByIdAndDelete(id?: mongodb.ObjectId | any, options?: QueryOptions | null, callback?: (err: CallbackError, doc: DocType | null, res: any) => void): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1774
|
+
findByIdAndDelete(id?: mongodb.ObjectId | any, options?: QueryOptions<DocType> | null, callback?: (err: CallbackError, doc: DocType | null, res: any) => void): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1654
1775
|
|
|
1655
1776
|
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
1656
|
-
findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery<DocType>, options: QueryOptions & { rawResult: true }, callback?: (err: CallbackError, doc: any, res?: any) => void): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1657
|
-
findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery<DocType>, options: QueryOptions & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: DocType, res?: any) => void): QueryWithHelpers<DocType, DocType, THelpers, RawDocType>;
|
|
1658
|
-
findByIdAndUpdate(id?: mongodb.ObjectId | any, update?: UpdateQuery<DocType>, options?: QueryOptions | null, callback?: (CallbackError: any, doc: DocType | null, res?: any) => void): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1777
|
+
findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery<DocType>, options: QueryOptions<DocType> & { rawResult: true }, callback?: (err: CallbackError, doc: any, res?: any) => void): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1778
|
+
findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery<DocType>, options: QueryOptions<DocType> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: DocType, res?: any) => void): QueryWithHelpers<DocType, DocType, THelpers, RawDocType>;
|
|
1779
|
+
findByIdAndUpdate(id?: mongodb.ObjectId | any, update?: UpdateQuery<DocType>, options?: QueryOptions<DocType> | null, callback?: (CallbackError: any, doc: DocType | null, res?: any) => void): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1659
1780
|
findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery<DocType>, callback: (CallbackError: any, doc: DocType | null, res?: any) => void): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
1660
1781
|
|
|
1661
1782
|
/** Specifies a `$geometry` condition */
|
|
@@ -1672,7 +1793,7 @@ declare module 'mongoose' {
|
|
|
1672
1793
|
getFilter(): FilterQuery<DocType>;
|
|
1673
1794
|
|
|
1674
1795
|
/** Gets query options. */
|
|
1675
|
-
getOptions(): QueryOptions
|
|
1796
|
+
getOptions(): QueryOptions<DocType>;
|
|
1676
1797
|
|
|
1677
1798
|
/** Gets a list of paths to be populated by this query */
|
|
1678
1799
|
getPopulatedPaths(): Array<string>;
|
|
@@ -1814,8 +1935,8 @@ declare module 'mongoose' {
|
|
|
1814
1935
|
* `update()`, except MongoDB will replace the existing document and will
|
|
1815
1936
|
* not accept any [atomic](https://docs.mongodb.com/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.)
|
|
1816
1937
|
*/
|
|
1817
|
-
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocType | AnyObject, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1818
|
-
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocType | AnyObject, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1938
|
+
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocType | AnyObject, options?: QueryOptions<DocType> | null, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1939
|
+
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocType | AnyObject, options?: QueryOptions<DocType> | null, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
1819
1940
|
|
|
1820
1941
|
/** Specifies which document fields to include or exclude (also known as the query "projection") */
|
|
1821
1942
|
select(arg: string | any): this;
|
|
@@ -1844,7 +1965,7 @@ declare module 'mongoose' {
|
|
|
1844
1965
|
set(path: string | Record<string, unknown>, value?: any): this;
|
|
1845
1966
|
|
|
1846
1967
|
/** Sets query options. Some options only make sense for certain operations. */
|
|
1847
|
-
setOptions(options: QueryOptions
|
|
1968
|
+
setOptions(options: QueryOptions<DocType>, overwrite?: boolean): this;
|
|
1848
1969
|
|
|
1849
1970
|
/** Sets the query conditions to the provided JSON object. */
|
|
1850
1971
|
setQuery(val: FilterQuery<DocType> | null): void;
|
|
@@ -1884,7 +2005,7 @@ declare module 'mongoose' {
|
|
|
1884
2005
|
toConstructor(): new (...args: any[]) => QueryWithHelpers<ResultType, DocType, THelpers, RawDocType>;
|
|
1885
2006
|
|
|
1886
2007
|
/** Declare and/or execute this query as an update() operation. */
|
|
1887
|
-
update(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
2008
|
+
update(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions<DocType> | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
1888
2009
|
|
|
1889
2010
|
/**
|
|
1890
2011
|
* Declare and/or execute this query as an updateMany() operation. Same as
|
|
@@ -1892,13 +2013,13 @@ declare module 'mongoose' {
|
|
|
1892
2013
|
* `filter` (as opposed to just the first one) regardless of the value of
|
|
1893
2014
|
* the `multi` option.
|
|
1894
2015
|
*/
|
|
1895
|
-
updateMany(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
2016
|
+
updateMany(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions<DocType> | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
1896
2017
|
|
|
1897
2018
|
/**
|
|
1898
2019
|
* Declare and/or execute this query as an updateOne() operation. Same as
|
|
1899
2020
|
* `update()`, except it does not support the `multi` or `overwrite` options.
|
|
1900
2021
|
*/
|
|
1901
|
-
updateOne(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
2022
|
+
updateOne(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions<DocType> | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
1902
2023
|
|
|
1903
2024
|
/**
|
|
1904
2025
|
* Sets the specified number of `mongod` servers, or tag set of `mongod` servers,
|
|
@@ -1922,6 +2043,9 @@ declare module 'mongoose' {
|
|
|
1922
2043
|
wtimeout(ms: number): this;
|
|
1923
2044
|
}
|
|
1924
2045
|
|
|
2046
|
+
type ProjectionElementType = number | string;
|
|
2047
|
+
export type ProjectionType<T> = { [P in keyof T]?: ProjectionElementType } | AnyObject | string;
|
|
2048
|
+
|
|
1925
2049
|
export type QuerySelector<T> = {
|
|
1926
2050
|
// Comparison
|
|
1927
2051
|
$eq?: T;
|
|
@@ -4,14 +4,20 @@ declare module 'mongoose' {
|
|
|
4
4
|
|
|
5
5
|
interface MongooseOptions {
|
|
6
6
|
/**
|
|
7
|
-
* Set to
|
|
7
|
+
* Set to `true` to set `allowDiskUse` to true to all aggregation operations by default.
|
|
8
|
+
*
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
allowDiskUse?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Set to `false` to skip applying global plugins to child schemas.
|
|
8
14
|
*
|
|
9
15
|
* @default true
|
|
10
16
|
*/
|
|
11
17
|
applyPluginsToChildSchemas?: boolean;
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
|
-
* Set to true to apply global plugins to discriminator schemas.
|
|
20
|
+
* Set to `true` to apply global plugins to discriminator schemas.
|
|
15
21
|
* This typically isn't necessary because plugins are applied to the base schema and
|
|
16
22
|
* discriminators copy all middleware, methods, statics, and properties from the base schema.
|
|
17
23
|
*
|
|
@@ -20,7 +26,7 @@ declare module 'mongoose' {
|
|
|
20
26
|
applyPluginsToDiscriminators?: boolean;
|
|
21
27
|
|
|
22
28
|
/**
|
|
23
|
-
* autoCreate is true by default unless readPreference is secondary or secondaryPreferred,
|
|
29
|
+
* autoCreate is `true` by default unless readPreference is secondary or secondaryPreferred,
|
|
24
30
|
* which means Mongoose will attempt to create every model's underlying collection before
|
|
25
31
|
* creating indexes. If readPreference is secondary or secondaryPreferred, Mongoose will
|
|
26
32
|
* default to false for both autoCreate and autoIndex because both createCollection() and
|
|
@@ -29,7 +35,7 @@ declare module 'mongoose' {
|
|
|
29
35
|
autoCreate?: boolean;
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
|
-
* Set to false to disable automatic index creation for all models associated with this Mongoose instance.
|
|
38
|
+
* Set to `false` to disable automatic index creation for all models associated with this Mongoose instance.
|
|
33
39
|
*
|
|
34
40
|
* @default true
|
|
35
41
|
*/
|