@depup/mongoose 9.1.3-depup.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/LICENSE.md +22 -0
- package/README.md +397 -0
- package/SECURITY.md +1 -0
- package/eslint.config.mjs +198 -0
- package/index.js +64 -0
- package/lib/aggregate.js +1189 -0
- package/lib/cast/bigint.js +46 -0
- package/lib/cast/boolean.js +32 -0
- package/lib/cast/date.js +41 -0
- package/lib/cast/decimal128.js +39 -0
- package/lib/cast/double.js +50 -0
- package/lib/cast/int32.js +36 -0
- package/lib/cast/number.js +42 -0
- package/lib/cast/objectid.js +29 -0
- package/lib/cast/string.js +37 -0
- package/lib/cast/uuid.js +35 -0
- package/lib/cast.js +436 -0
- package/lib/collection.js +321 -0
- package/lib/connection.js +1855 -0
- package/lib/connectionState.js +26 -0
- package/lib/constants.js +73 -0
- package/lib/cursor/aggregationCursor.js +466 -0
- package/lib/cursor/changeStream.js +198 -0
- package/lib/cursor/queryCursor.js +622 -0
- package/lib/document.js +5521 -0
- package/lib/driver.js +15 -0
- package/lib/drivers/SPEC.md +4 -0
- package/lib/drivers/node-mongodb-native/bulkWriteResult.js +5 -0
- package/lib/drivers/node-mongodb-native/collection.js +393 -0
- package/lib/drivers/node-mongodb-native/connection.js +506 -0
- package/lib/drivers/node-mongodb-native/index.js +10 -0
- package/lib/error/browserMissingSchema.js +29 -0
- package/lib/error/bulkSaveIncompleteError.js +44 -0
- package/lib/error/bulkWriteError.js +41 -0
- package/lib/error/cast.js +158 -0
- package/lib/error/createCollectionsError.js +26 -0
- package/lib/error/divergentArray.js +40 -0
- package/lib/error/eachAsyncMultiError.js +41 -0
- package/lib/error/index.js +237 -0
- package/lib/error/invalidSchemaOption.js +32 -0
- package/lib/error/messages.js +47 -0
- package/lib/error/missingSchema.js +33 -0
- package/lib/error/mongooseError.js +13 -0
- package/lib/error/notFound.js +47 -0
- package/lib/error/objectExpected.js +31 -0
- package/lib/error/objectParameter.js +31 -0
- package/lib/error/overwriteModel.js +31 -0
- package/lib/error/parallelSave.js +33 -0
- package/lib/error/parallelValidate.js +33 -0
- package/lib/error/serverSelection.js +62 -0
- package/lib/error/setOptionError.js +103 -0
- package/lib/error/strict.js +35 -0
- package/lib/error/strictPopulate.js +31 -0
- package/lib/error/syncIndexes.js +30 -0
- package/lib/error/validation.js +97 -0
- package/lib/error/validator.js +100 -0
- package/lib/error/version.js +38 -0
- package/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +39 -0
- package/lib/helpers/aggregate/stringifyFunctionOperators.js +50 -0
- package/lib/helpers/arrayDepth.js +33 -0
- package/lib/helpers/clone.js +204 -0
- package/lib/helpers/common.js +127 -0
- package/lib/helpers/createJSONSchemaTypeDefinition.js +24 -0
- package/lib/helpers/cursor/eachAsync.js +225 -0
- package/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +36 -0
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
- package/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +12 -0
- package/lib/helpers/discriminator/getConstructor.js +29 -0
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +28 -0
- package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +27 -0
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +91 -0
- package/lib/helpers/document/applyDefaults.js +132 -0
- package/lib/helpers/document/applyTimestamps.js +106 -0
- package/lib/helpers/document/applyVirtuals.js +147 -0
- package/lib/helpers/document/cleanModifiedSubpaths.js +45 -0
- package/lib/helpers/document/compile.js +238 -0
- package/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +53 -0
- package/lib/helpers/document/handleSpreadDoc.js +35 -0
- package/lib/helpers/each.js +25 -0
- package/lib/helpers/error/combinePathErrors.js +22 -0
- package/lib/helpers/firstKey.js +8 -0
- package/lib/helpers/get.js +65 -0
- package/lib/helpers/getConstructorName.js +16 -0
- package/lib/helpers/getDefaultBulkwriteResult.js +18 -0
- package/lib/helpers/getFunctionName.js +10 -0
- package/lib/helpers/immediate.js +16 -0
- package/lib/helpers/indexes/applySchemaCollation.js +13 -0
- package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
- package/lib/helpers/indexes/getRelatedIndexes.js +63 -0
- package/lib/helpers/indexes/isDefaultIdIndex.js +18 -0
- package/lib/helpers/indexes/isIndexEqual.js +95 -0
- package/lib/helpers/indexes/isIndexSpecEqual.js +32 -0
- package/lib/helpers/indexes/isTextIndex.js +16 -0
- package/lib/helpers/indexes/isTimeseriesIndex.js +16 -0
- package/lib/helpers/isAsyncFunction.js +9 -0
- package/lib/helpers/isBsonType.js +15 -0
- package/lib/helpers/isMongooseObject.js +22 -0
- package/lib/helpers/isObject.js +16 -0
- package/lib/helpers/isPOJO.js +12 -0
- package/lib/helpers/isPromise.js +6 -0
- package/lib/helpers/isSimpleValidator.js +22 -0
- package/lib/helpers/minimize.js +41 -0
- package/lib/helpers/model/applyDefaultsToPOJO.js +52 -0
- package/lib/helpers/model/applyHooks.js +140 -0
- package/lib/helpers/model/applyMethods.js +70 -0
- package/lib/helpers/model/applyStaticHooks.js +33 -0
- package/lib/helpers/model/applyStatics.js +13 -0
- package/lib/helpers/model/castBulkWrite.js +316 -0
- package/lib/helpers/model/decorateBulkWriteResult.js +8 -0
- package/lib/helpers/model/discriminator.js +265 -0
- package/lib/helpers/model/pushNestedArrayPaths.js +15 -0
- package/lib/helpers/omitUndefined.js +20 -0
- package/lib/helpers/once.js +12 -0
- package/lib/helpers/parallelLimit.js +37 -0
- package/lib/helpers/path/parentPaths.js +18 -0
- package/lib/helpers/path/setDottedPath.js +33 -0
- package/lib/helpers/pluralize.js +95 -0
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +129 -0
- package/lib/helpers/populate/assignVals.js +360 -0
- package/lib/helpers/populate/createPopulateQueryFilter.js +97 -0
- package/lib/helpers/populate/getModelsMapForPopulate.js +776 -0
- package/lib/helpers/populate/getSchemaTypes.js +228 -0
- package/lib/helpers/populate/getVirtual.js +103 -0
- package/lib/helpers/populate/leanPopulateMap.js +7 -0
- package/lib/helpers/populate/lookupLocalFields.js +40 -0
- package/lib/helpers/populate/markArraySubdocsPopulated.js +49 -0
- package/lib/helpers/populate/modelNamesFromRefPath.js +66 -0
- package/lib/helpers/populate/removeDeselectedForeignField.js +31 -0
- package/lib/helpers/populate/setPopulatedVirtualValue.js +33 -0
- package/lib/helpers/populate/skipPopulateValue.js +10 -0
- package/lib/helpers/populate/validateRef.js +19 -0
- package/lib/helpers/printJestWarning.js +21 -0
- package/lib/helpers/processConnectionOptions.js +65 -0
- package/lib/helpers/projection/applyProjection.js +83 -0
- package/lib/helpers/projection/hasIncludedChildren.js +41 -0
- package/lib/helpers/projection/isDefiningProjection.js +18 -0
- package/lib/helpers/projection/isExclusive.js +37 -0
- package/lib/helpers/projection/isInclusive.js +39 -0
- package/lib/helpers/projection/isNestedProjection.js +8 -0
- package/lib/helpers/projection/isPathExcluded.js +40 -0
- package/lib/helpers/projection/isPathSelectedInclusive.js +28 -0
- package/lib/helpers/projection/isSubpath.js +14 -0
- package/lib/helpers/projection/parseProjection.js +33 -0
- package/lib/helpers/query/applyGlobalOption.js +29 -0
- package/lib/helpers/query/cast$expr.js +287 -0
- package/lib/helpers/query/castFilterPath.js +54 -0
- package/lib/helpers/query/castUpdate.js +643 -0
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +103 -0
- package/lib/helpers/query/handleImmutable.js +44 -0
- package/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
- package/lib/helpers/query/hasDollarKeys.js +23 -0
- package/lib/helpers/query/isOperator.js +14 -0
- package/lib/helpers/query/sanitizeFilter.js +38 -0
- package/lib/helpers/query/sanitizeProjection.js +14 -0
- package/lib/helpers/query/selectPopulatedFields.js +62 -0
- package/lib/helpers/query/trusted.js +13 -0
- package/lib/helpers/query/validOps.js +3 -0
- package/lib/helpers/schema/addAutoId.js +7 -0
- package/lib/helpers/schema/applyBuiltinPlugins.js +12 -0
- package/lib/helpers/schema/applyPlugins.js +55 -0
- package/lib/helpers/schema/applyReadConcern.js +20 -0
- package/lib/helpers/schema/applyWriteConcern.js +39 -0
- package/lib/helpers/schema/cleanPositionalOperators.js +12 -0
- package/lib/helpers/schema/getIndexes.js +171 -0
- package/lib/helpers/schema/getKeysInSchemaOrder.js +28 -0
- package/lib/helpers/schema/getPath.js +43 -0
- package/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
- package/lib/helpers/schema/handleIdOption.js +20 -0
- package/lib/helpers/schema/handleTimestampOption.js +24 -0
- package/lib/helpers/schema/idGetter.js +34 -0
- package/lib/helpers/schema/merge.js +36 -0
- package/lib/helpers/schematype/handleImmutable.js +50 -0
- package/lib/helpers/setDefaultsOnInsert.js +158 -0
- package/lib/helpers/specialProperties.js +3 -0
- package/lib/helpers/symbols.js +20 -0
- package/lib/helpers/timers.js +3 -0
- package/lib/helpers/timestamps/setDocumentTimestamps.js +26 -0
- package/lib/helpers/timestamps/setupTimestamps.js +116 -0
- package/lib/helpers/topology/allServersUnknown.js +12 -0
- package/lib/helpers/topology/isAtlas.js +31 -0
- package/lib/helpers/topology/isSSLError.js +16 -0
- package/lib/helpers/update/applyTimestampsToChildren.js +193 -0
- package/lib/helpers/update/applyTimestampsToUpdate.js +131 -0
- package/lib/helpers/update/castArrayFilters.js +113 -0
- package/lib/helpers/update/decorateUpdateWithVersionKey.js +35 -0
- package/lib/helpers/update/modifiedPaths.js +33 -0
- package/lib/helpers/update/moveImmutableProperties.js +53 -0
- package/lib/helpers/update/removeUnusedArrayFilters.js +32 -0
- package/lib/helpers/update/updatedPathsByArrayFilter.js +27 -0
- package/lib/helpers/updateValidators.js +193 -0
- package/lib/index.js +17 -0
- package/lib/internal.js +46 -0
- package/lib/model.js +5010 -0
- package/lib/modifiedPathsSnapshot.js +9 -0
- package/lib/mongoose.js +1411 -0
- package/lib/options/populateOptions.js +36 -0
- package/lib/options/propertyOptions.js +8 -0
- package/lib/options/saveOptions.js +16 -0
- package/lib/options/schemaArrayOptions.js +78 -0
- package/lib/options/schemaBufferOptions.js +38 -0
- package/lib/options/schemaDateOptions.js +71 -0
- package/lib/options/schemaDocumentArrayOptions.js +68 -0
- package/lib/options/schemaMapOptions.js +43 -0
- package/lib/options/schemaNumberOptions.js +101 -0
- package/lib/options/schemaObjectIdOptions.js +64 -0
- package/lib/options/schemaStringOptions.js +138 -0
- package/lib/options/schemaSubdocumentOptions.js +66 -0
- package/lib/options/schemaTypeOptions.js +244 -0
- package/lib/options/schemaUnionOptions.js +32 -0
- package/lib/options/virtualOptions.js +164 -0
- package/lib/options.js +17 -0
- package/lib/plugins/index.js +6 -0
- package/lib/plugins/saveSubdocs.js +76 -0
- package/lib/plugins/sharding.js +84 -0
- package/lib/plugins/trackTransaction.js +84 -0
- package/lib/plugins/validateBeforeSave.js +41 -0
- package/lib/query.js +5673 -0
- package/lib/queryHelpers.js +387 -0
- package/lib/schema/array.js +699 -0
- package/lib/schema/bigint.js +282 -0
- package/lib/schema/boolean.js +332 -0
- package/lib/schema/buffer.js +343 -0
- package/lib/schema/date.js +467 -0
- package/lib/schema/decimal128.js +263 -0
- package/lib/schema/documentArray.js +656 -0
- package/lib/schema/documentArrayElement.js +137 -0
- package/lib/schema/double.js +246 -0
- package/lib/schema/index.js +32 -0
- package/lib/schema/int32.js +289 -0
- package/lib/schema/map.js +201 -0
- package/lib/schema/mixed.js +146 -0
- package/lib/schema/number.js +510 -0
- package/lib/schema/objectId.js +333 -0
- package/lib/schema/operators/bitwise.js +38 -0
- package/lib/schema/operators/exists.js +12 -0
- package/lib/schema/operators/geospatial.js +107 -0
- package/lib/schema/operators/helpers.js +32 -0
- package/lib/schema/operators/text.js +39 -0
- package/lib/schema/operators/type.js +20 -0
- package/lib/schema/string.js +733 -0
- package/lib/schema/subdocument.js +436 -0
- package/lib/schema/symbols.js +5 -0
- package/lib/schema/union.js +113 -0
- package/lib/schema/uuid.js +305 -0
- package/lib/schema.js +3226 -0
- package/lib/schemaType.js +1835 -0
- package/lib/stateMachine.js +232 -0
- package/lib/types/array/index.js +119 -0
- package/lib/types/array/isMongooseArray.js +5 -0
- package/lib/types/array/methods/index.js +1095 -0
- package/lib/types/arraySubdocument.js +207 -0
- package/lib/types/buffer.js +294 -0
- package/lib/types/decimal128.js +13 -0
- package/lib/types/documentArray/index.js +113 -0
- package/lib/types/documentArray/isMongooseDocumentArray.js +5 -0
- package/lib/types/documentArray/methods/index.js +415 -0
- package/lib/types/double.js +13 -0
- package/lib/types/index.js +23 -0
- package/lib/types/map.js +419 -0
- package/lib/types/objectid.js +41 -0
- package/lib/types/subdocument.js +464 -0
- package/lib/types/uuid.js +13 -0
- package/lib/utils.js +1054 -0
- package/lib/validOptions.js +42 -0
- package/lib/virtualType.js +204 -0
- package/package.json +148 -0
- package/types/aggregate.d.ts +180 -0
- package/types/augmentations.d.ts +9 -0
- package/types/callback.d.ts +8 -0
- package/types/collection.d.ts +49 -0
- package/types/connection.d.ts +297 -0
- package/types/cursor.d.ts +67 -0
- package/types/document.d.ts +374 -0
- package/types/error.d.ts +143 -0
- package/types/expressions.d.ts +3053 -0
- package/types/helpers.d.ts +32 -0
- package/types/index.d.ts +1056 -0
- package/types/indexes.d.ts +97 -0
- package/types/inferhydrateddoctype.d.ts +115 -0
- package/types/inferrawdoctype.d.ts +135 -0
- package/types/inferschematype.d.ts +337 -0
- package/types/middlewares.d.ts +59 -0
- package/types/models.d.ts +1306 -0
- package/types/mongooseoptions.d.ts +228 -0
- package/types/pipelinestage.d.ts +333 -0
- package/types/populate.d.ts +53 -0
- package/types/query.d.ts +934 -0
- package/types/schemaoptions.d.ts +282 -0
- package/types/schematypes.d.ts +654 -0
- package/types/session.d.ts +32 -0
- package/types/types.d.ts +109 -0
- package/types/utility.d.ts +175 -0
- package/types/validation.d.ts +39 -0
- package/types/virtuals.d.ts +14 -0
package/types/query.d.ts
ADDED
|
@@ -0,0 +1,934 @@
|
|
|
1
|
+
declare module 'mongoose' {
|
|
2
|
+
import mongodb = require('mongodb');
|
|
3
|
+
|
|
4
|
+
type StringQueryTypeCasting = string | RegExp;
|
|
5
|
+
type ObjectIdQueryTypeCasting = Types.ObjectId | string;
|
|
6
|
+
type DateQueryTypeCasting = string | number | NativeDate;
|
|
7
|
+
type UUIDQueryTypeCasting = Types.UUID | string;
|
|
8
|
+
type BufferQueryCasting = Buffer | mongodb.Binary | number[] | string | { $binary: string | mongodb.Binary };
|
|
9
|
+
type QueryTypeCasting<T> = T extends string
|
|
10
|
+
? StringQueryTypeCasting
|
|
11
|
+
: T extends Types.ObjectId
|
|
12
|
+
? ObjectIdQueryTypeCasting
|
|
13
|
+
: T extends Types.UUID
|
|
14
|
+
? UUIDQueryTypeCasting
|
|
15
|
+
: T extends Buffer
|
|
16
|
+
? BufferQueryCasting
|
|
17
|
+
: T extends NativeDate
|
|
18
|
+
? DateQueryTypeCasting
|
|
19
|
+
: T;
|
|
20
|
+
|
|
21
|
+
export type ApplyBasicQueryCasting<T> = QueryTypeCasting<T> | QueryTypeCasting<T[]> | (T extends (infer U)[] ? QueryTypeCasting<U> : T) | null;
|
|
22
|
+
|
|
23
|
+
type _QueryFilter<T> = ({ [P in keyof T]?: mongodb.Condition<ApplyBasicQueryCasting<T[P]>>; } & mongodb.RootFilterOperators<{ [P in keyof mongodb.WithId<T>]?: ApplyBasicQueryCasting<mongodb.WithId<T>[P]>; }>);
|
|
24
|
+
type QueryFilter<T> = IsItRecordAndNotAny<T> extends true ? _QueryFilter<WithLevel1NestedPaths<T>> : _QueryFilter<Record<string, any>>;
|
|
25
|
+
|
|
26
|
+
type MongooseBaseQueryOptionKeys =
|
|
27
|
+
| 'context'
|
|
28
|
+
| 'multipleCastError'
|
|
29
|
+
| 'overwriteDiscriminatorKey'
|
|
30
|
+
| 'overwriteImmutable'
|
|
31
|
+
| 'populate'
|
|
32
|
+
| 'runValidators'
|
|
33
|
+
| 'sanitizeProjection'
|
|
34
|
+
| 'sanitizeFilter'
|
|
35
|
+
| 'schemaLevelProjections'
|
|
36
|
+
| 'setDefaultsOnInsert'
|
|
37
|
+
| 'strict'
|
|
38
|
+
| 'strictQuery'
|
|
39
|
+
| 'translateAliases'
|
|
40
|
+
| 'updatePipeline';
|
|
41
|
+
|
|
42
|
+
type MongooseBaseQueryOptions<DocType = unknown> = Pick<QueryOptions<DocType>, MongooseBaseQueryOptionKeys | 'timestamps' | 'lean'> & {
|
|
43
|
+
[other: string]: any;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type MongooseUpdateQueryOptions<DocType = unknown> = Pick<QueryOptions<DocType>, MongooseBaseQueryOptionKeys | 'timestamps'>;
|
|
47
|
+
|
|
48
|
+
type ProjectionFields<DocType> = { [Key in keyof DocType]?: any } & Record<string, any>;
|
|
49
|
+
|
|
50
|
+
type QueryWithHelpers<
|
|
51
|
+
ResultType,
|
|
52
|
+
DocType,
|
|
53
|
+
THelpers = {},
|
|
54
|
+
RawDocType = DocType,
|
|
55
|
+
QueryOp = 'find',
|
|
56
|
+
TDocOverrides = Record<string, never>
|
|
57
|
+
> = Query<ResultType, DocType, THelpers, RawDocType, QueryOp, TDocOverrides> & THelpers;
|
|
58
|
+
|
|
59
|
+
interface QueryTimestampsConfig {
|
|
60
|
+
createdAt?: boolean;
|
|
61
|
+
updatedAt?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Options that can be passed to Query.prototype.lean()
|
|
65
|
+
interface LeanOptions {
|
|
66
|
+
// Set to false to strip out the version key
|
|
67
|
+
versionKey?: boolean;
|
|
68
|
+
// Transform the result document in place. `doc` is the raw document being transformed.
|
|
69
|
+
// Typed as `Record<string, unknown>` because TypeScript gets confused when handling Document.prototype.deleteOne()
|
|
70
|
+
// and other document methods that try to infer the raw doc type from the Document class.
|
|
71
|
+
transform?: (doc: Record<string, unknown>) => void;
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface QueryOptions<DocType = unknown> extends
|
|
76
|
+
PopulateOption,
|
|
77
|
+
SessionOption {
|
|
78
|
+
arrayFilters?: AnyObject[];
|
|
79
|
+
batchSize?: number;
|
|
80
|
+
collation?: mongodb.CollationOptions;
|
|
81
|
+
comment?: any;
|
|
82
|
+
context?: string;
|
|
83
|
+
explain?: mongodb.ExplainVerbosityLike;
|
|
84
|
+
fields?: any | string;
|
|
85
|
+
hint?: mongodb.Hint;
|
|
86
|
+
/**
|
|
87
|
+
* If truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document.
|
|
88
|
+
*/
|
|
89
|
+
lean?: boolean | LeanOptions;
|
|
90
|
+
limit?: number;
|
|
91
|
+
maxTimeMS?: number;
|
|
92
|
+
multi?: boolean;
|
|
93
|
+
multipleCastError?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* By default, `findOneAndUpdate()` returns the document as it was **before**
|
|
96
|
+
* `update` was applied. If you set `new: true`, `findOneAndUpdate()` will
|
|
97
|
+
* instead give you the object after `update` was applied.
|
|
98
|
+
*/
|
|
99
|
+
new?: boolean;
|
|
100
|
+
|
|
101
|
+
overwriteDiscriminatorKey?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert).
|
|
104
|
+
* Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
|
|
105
|
+
*/
|
|
106
|
+
overwriteImmutable?: boolean;
|
|
107
|
+
projection?: AnyObject | string;
|
|
108
|
+
/**
|
|
109
|
+
* if true, returns the full ModifyResult rather than just the document
|
|
110
|
+
*/
|
|
111
|
+
includeResultMetadata?: boolean;
|
|
112
|
+
readPreference?: string | mongodb.ReadPreferenceMode;
|
|
113
|
+
/**
|
|
114
|
+
* An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`.
|
|
115
|
+
*/
|
|
116
|
+
returnOriginal?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Another alias for the `new` option. `returnOriginal` is deprecated so this should be used.
|
|
119
|
+
*/
|
|
120
|
+
returnDocument?: 'before' | 'after';
|
|
121
|
+
/**
|
|
122
|
+
* Set to true to enable `update validators`
|
|
123
|
+
* (https://mongoosejs.com/docs/validation.html#update-validators). Defaults to false.
|
|
124
|
+
*/
|
|
125
|
+
runValidators?: boolean;
|
|
126
|
+
/* Set to `true` to automatically sanitize potentially unsafe user-generated query projections */
|
|
127
|
+
sanitizeProjection?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Set to `true` to automatically sanitize potentially unsafe query filters by stripping out query selectors that
|
|
130
|
+
* aren't explicitly allowed using `mongoose.trusted()`.
|
|
131
|
+
*/
|
|
132
|
+
sanitizeFilter?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Enable or disable schema level projections for this query. Enabled by default.
|
|
135
|
+
* Set to `false` to include fields with `select: false` in the query result by default.
|
|
136
|
+
*/
|
|
137
|
+
schemaLevelProjections?: boolean;
|
|
138
|
+
setDefaultsOnInsert?: boolean;
|
|
139
|
+
skip?: number;
|
|
140
|
+
sort?: any;
|
|
141
|
+
/** overwrites the schema's strict mode option */
|
|
142
|
+
strict?: boolean | string;
|
|
143
|
+
/**
|
|
144
|
+
* equal to `strict` by default, may be `false`, `true`, or `'throw'`. Sets the default
|
|
145
|
+
* [strictQuery](https://mongoosejs.com/docs/guide.html#strictQuery) mode for schemas.
|
|
146
|
+
*/
|
|
147
|
+
strictQuery?: boolean | 'throw';
|
|
148
|
+
tailable?: number;
|
|
149
|
+
/**
|
|
150
|
+
* If set to `false` and schema-level timestamps are enabled,
|
|
151
|
+
* skip timestamps for this update. Note that this allows you to overwrite
|
|
152
|
+
* timestamps. Does nothing if schema-level timestamps are not set.
|
|
153
|
+
*/
|
|
154
|
+
timestamps?: boolean | QueryTimestampsConfig;
|
|
155
|
+
/**
|
|
156
|
+
* If `true`, convert any aliases in filter, projection, update, and distinct
|
|
157
|
+
* to their database property names. Defaults to false.
|
|
158
|
+
*/
|
|
159
|
+
translateAliases?: boolean;
|
|
160
|
+
upsert?: boolean;
|
|
161
|
+
useBigInt64?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Set to true to allow passing in an update pipeline instead of an update document.
|
|
164
|
+
* Mongoose disallows update pipelines by default because Mongoose does not cast update pipelines.
|
|
165
|
+
*/
|
|
166
|
+
updatePipeline?: boolean;
|
|
167
|
+
writeConcern?: mongodb.WriteConcern;
|
|
168
|
+
|
|
169
|
+
[other: string]: any;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
type QueryOpThatReturnsDocument = 'find' | 'findOne' | 'findOneAndUpdate' | 'findOneAndReplace' | 'findOneAndDelete';
|
|
173
|
+
|
|
174
|
+
type GetLeanResultType<RawDocType, ResultType, QueryOp> = QueryOp extends QueryOpThatReturnsDocument
|
|
175
|
+
? (ResultType extends any[] ? Default__v<Require_id<RawDocType>>[] : Default__v<Require_id<RawDocType>>)
|
|
176
|
+
: ResultType;
|
|
177
|
+
|
|
178
|
+
type MergePopulatePaths<RawDocType, ResultType, QueryOp, Paths, TQueryHelpers, TDocOverrides = Record<string, never>> = QueryOp extends QueryOpThatReturnsDocument
|
|
179
|
+
? ResultType extends null
|
|
180
|
+
? ResultType
|
|
181
|
+
: ResultType extends (infer U)[]
|
|
182
|
+
? U extends Document
|
|
183
|
+
? HydratedDocument<MergeType<RawDocType, Paths>, TDocOverrides, TQueryHelpers>[]
|
|
184
|
+
: (MergeType<U, Paths>)[]
|
|
185
|
+
: ResultType extends Document
|
|
186
|
+
? HydratedDocument<MergeType<RawDocType, Paths>, TDocOverrides, TQueryHelpers>
|
|
187
|
+
: MergeType<ResultType, Paths>
|
|
188
|
+
: MergeType<ResultType, Paths>;
|
|
189
|
+
|
|
190
|
+
class Query<ResultType, DocType, THelpers = {}, RawDocType = unknown, QueryOp = 'find', TDocOverrides = Record<string, never>> implements SessionOperation {
|
|
191
|
+
_mongooseOptions: QueryOptions<RawDocType>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Returns a wrapper around a [mongodb driver cursor](https://mongodb.github.io/node-mongodb-native/4.9/classes/FindCursor.html).
|
|
195
|
+
* A QueryCursor exposes a Streams3 interface, as well as a `.next()` function.
|
|
196
|
+
* This is equivalent to calling `.cursor()` with no arguments.
|
|
197
|
+
*/
|
|
198
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<Unpacked<ResultType>>;
|
|
199
|
+
|
|
200
|
+
/** Executes the query */
|
|
201
|
+
exec(): Promise<ResultType>;
|
|
202
|
+
|
|
203
|
+
$where(argument: string | Function): QueryWithHelpers<
|
|
204
|
+
DocType[],
|
|
205
|
+
DocType,
|
|
206
|
+
THelpers,
|
|
207
|
+
RawDocType,
|
|
208
|
+
QueryOp,
|
|
209
|
+
TDocOverrides
|
|
210
|
+
>;
|
|
211
|
+
|
|
212
|
+
/** Specifies an `$all` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
213
|
+
all(path: string, val: Array<any>): this;
|
|
214
|
+
all(val: Array<any>): this;
|
|
215
|
+
|
|
216
|
+
/** Sets the allowDiskUse option for the query (ignored for < 4.4.0) */
|
|
217
|
+
allowDiskUse(value: boolean): this;
|
|
218
|
+
|
|
219
|
+
/** Specifies arguments for an `$and` condition. */
|
|
220
|
+
and(array: QueryFilter<RawDocType>[]): this;
|
|
221
|
+
|
|
222
|
+
/** Specifies the batchSize option. */
|
|
223
|
+
batchSize(val: number): this;
|
|
224
|
+
|
|
225
|
+
/** Specifies a `$box` condition */
|
|
226
|
+
box(lower: number[], upper: number[]): this;
|
|
227
|
+
box(val: any): this;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Casts this query to the schema of `model`.
|
|
231
|
+
*
|
|
232
|
+
* @param {Model} [model] the model to cast to. If not set, defaults to `this.model`
|
|
233
|
+
* @param {Object} [obj] If not set, defaults to this query's conditions
|
|
234
|
+
* @return {Object} the casted `obj`
|
|
235
|
+
*/
|
|
236
|
+
cast(model?: Model<any, THelpers> | null, obj?: any): any;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Executes the query returning a `Promise` which will be
|
|
240
|
+
* resolved with either the doc(s) or rejected with the error.
|
|
241
|
+
* Like `.then()`, but only takes a rejection handler.
|
|
242
|
+
*/
|
|
243
|
+
catch: Promise<ResultType>['catch'];
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Executes the query returning a `Promise` which will be
|
|
247
|
+
* resolved with `.finally()` chained.
|
|
248
|
+
*/
|
|
249
|
+
finally: Promise<ResultType>['finally'];
|
|
250
|
+
|
|
251
|
+
// Returns a string representation of this query.
|
|
252
|
+
[Symbol.toStringTag]: string;
|
|
253
|
+
|
|
254
|
+
/** Specifies a `$center` or `$centerSphere` condition. */
|
|
255
|
+
circle(path: string, area: any): this;
|
|
256
|
+
circle(area: any): this;
|
|
257
|
+
|
|
258
|
+
/** Make a copy of this query so you can re-execute it. */
|
|
259
|
+
clone(): this;
|
|
260
|
+
|
|
261
|
+
/** Adds a collation to this op (MongoDB 3.4 and up) */
|
|
262
|
+
collation(value: mongodb.CollationOptions): this;
|
|
263
|
+
|
|
264
|
+
/** Specifies the `comment` option. */
|
|
265
|
+
comment(val: string): this;
|
|
266
|
+
|
|
267
|
+
/** Specifies this query as a `countDocuments` query. */
|
|
268
|
+
countDocuments(
|
|
269
|
+
criteria?: QueryFilter<RawDocType>,
|
|
270
|
+
options?: QueryOptions<RawDocType>
|
|
271
|
+
): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments', TDocOverrides>;
|
|
272
|
+
countDocuments(
|
|
273
|
+
criteria?: Query<any, any>,
|
|
274
|
+
options?: QueryOptions<RawDocType>
|
|
275
|
+
): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments', TDocOverrides>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Returns a wrapper around a [mongodb driver cursor](https://mongodb.github.io/node-mongodb-native/4.9/classes/FindCursor.html).
|
|
279
|
+
* A QueryCursor exposes a Streams3 interface, as well as a `.next()` function.
|
|
280
|
+
*/
|
|
281
|
+
cursor(options?: QueryOptions<RawDocType>): Cursor<Unpacked<ResultType>, QueryOptions<RawDocType>>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Declare and/or execute this query as a `deleteMany()` operation. Works like
|
|
285
|
+
* remove, except it deletes _every_ document that matches `filter` in the
|
|
286
|
+
* collection, regardless of the value of `single`.
|
|
287
|
+
*/
|
|
288
|
+
deleteMany(
|
|
289
|
+
filter?: QueryFilter<RawDocType>,
|
|
290
|
+
options?: QueryOptions<RawDocType>
|
|
291
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides>;
|
|
292
|
+
deleteMany(
|
|
293
|
+
filter?: Query<any, any>,
|
|
294
|
+
options?: QueryOptions<RawDocType>
|
|
295
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides>;
|
|
296
|
+
deleteMany(filter: QueryFilter<RawDocType>): QueryWithHelpers<
|
|
297
|
+
any,
|
|
298
|
+
DocType,
|
|
299
|
+
THelpers,
|
|
300
|
+
RawDocType,
|
|
301
|
+
'deleteMany',
|
|
302
|
+
TDocOverrides
|
|
303
|
+
>;
|
|
304
|
+
deleteMany(filter: Query<any, any>): QueryWithHelpers<
|
|
305
|
+
any,
|
|
306
|
+
DocType,
|
|
307
|
+
THelpers,
|
|
308
|
+
RawDocType,
|
|
309
|
+
'deleteMany',
|
|
310
|
+
TDocOverrides
|
|
311
|
+
>;
|
|
312
|
+
deleteMany(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TDocOverrides>;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Declare and/or execute this query as a `deleteOne()` operation. Works like
|
|
316
|
+
* remove, except it deletes at most one document regardless of the `single`
|
|
317
|
+
* option.
|
|
318
|
+
*/
|
|
319
|
+
deleteOne(
|
|
320
|
+
filter?: QueryFilter<RawDocType>,
|
|
321
|
+
options?: QueryOptions<RawDocType>
|
|
322
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides>;
|
|
323
|
+
deleteOne(
|
|
324
|
+
filter?: Query<any, any>,
|
|
325
|
+
options?: QueryOptions<RawDocType>
|
|
326
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides>;
|
|
327
|
+
deleteOne(filter: QueryFilter<RawDocType>): QueryWithHelpers<
|
|
328
|
+
any,
|
|
329
|
+
DocType,
|
|
330
|
+
THelpers,
|
|
331
|
+
RawDocType,
|
|
332
|
+
'deleteOne',
|
|
333
|
+
TDocOverrides
|
|
334
|
+
>;
|
|
335
|
+
deleteOne(filter: Query<any, any>): QueryWithHelpers<
|
|
336
|
+
any,
|
|
337
|
+
DocType,
|
|
338
|
+
THelpers,
|
|
339
|
+
RawDocType,
|
|
340
|
+
'deleteOne',
|
|
341
|
+
TDocOverrides
|
|
342
|
+
>;
|
|
343
|
+
deleteOne(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TDocOverrides>;
|
|
344
|
+
|
|
345
|
+
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
346
|
+
distinct<DocKey extends string, ResultType = unknown>(
|
|
347
|
+
field: DocKey,
|
|
348
|
+
filter?: QueryFilter<RawDocType>,
|
|
349
|
+
options?: QueryOptions<RawDocType>
|
|
350
|
+
): QueryWithHelpers<
|
|
351
|
+
Array<
|
|
352
|
+
DocKey extends keyof WithLevel1NestedPaths<DocType>
|
|
353
|
+
? WithoutUndefined<Unpacked<WithLevel1NestedPaths<DocType>[DocKey]>>
|
|
354
|
+
: ResultType
|
|
355
|
+
>,
|
|
356
|
+
DocType,
|
|
357
|
+
THelpers,
|
|
358
|
+
RawDocType,
|
|
359
|
+
'distinct',
|
|
360
|
+
TDocOverrides
|
|
361
|
+
>;
|
|
362
|
+
distinct<DocKey extends string, ResultType = unknown>(
|
|
363
|
+
field: DocKey,
|
|
364
|
+
filter?: Query<any, any>,
|
|
365
|
+
options?: QueryOptions<RawDocType>
|
|
366
|
+
): QueryWithHelpers<
|
|
367
|
+
Array<
|
|
368
|
+
DocKey extends keyof WithLevel1NestedPaths<DocType>
|
|
369
|
+
? WithoutUndefined<Unpacked<WithLevel1NestedPaths<DocType>[DocKey]>>
|
|
370
|
+
: ResultType
|
|
371
|
+
>,
|
|
372
|
+
DocType,
|
|
373
|
+
THelpers,
|
|
374
|
+
RawDocType,
|
|
375
|
+
'distinct',
|
|
376
|
+
TDocOverrides
|
|
377
|
+
>;
|
|
378
|
+
|
|
379
|
+
/** Specifies a `$elemMatch` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
380
|
+
elemMatch(path: string, val: any): this;
|
|
381
|
+
elemMatch(val: Function | any): this;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Gets/sets the error flag on this query. If this flag is not null or
|
|
385
|
+
* undefined, the `exec()` promise will reject without executing.
|
|
386
|
+
*/
|
|
387
|
+
error(): NativeError | null;
|
|
388
|
+
error(val: NativeError | null): this;
|
|
389
|
+
|
|
390
|
+
/** Specifies the complementary comparison value for paths specified with `where()` */
|
|
391
|
+
equals(val: any): this;
|
|
392
|
+
|
|
393
|
+
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
394
|
+
estimatedDocumentCount(options?: QueryOptions<RawDocType>): QueryWithHelpers<
|
|
395
|
+
number,
|
|
396
|
+
DocType,
|
|
397
|
+
THelpers,
|
|
398
|
+
RawDocType,
|
|
399
|
+
'estimatedDocumentCount',
|
|
400
|
+
TDocOverrides
|
|
401
|
+
>;
|
|
402
|
+
|
|
403
|
+
/** Specifies a `$exists` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
404
|
+
exists(path: string, val: boolean): this;
|
|
405
|
+
exists(val: boolean): this;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Sets the [`explain` option](https://www.mongodb.com/docs/manual/reference/method/cursor.explain/),
|
|
409
|
+
* which makes this query return detailed execution stats instead of the actual
|
|
410
|
+
* query result. This method is useful for determining what index your queries
|
|
411
|
+
* use.
|
|
412
|
+
*/
|
|
413
|
+
explain(verbose?: mongodb.ExplainVerbosityLike): this;
|
|
414
|
+
|
|
415
|
+
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
416
|
+
find(
|
|
417
|
+
filter?: QueryFilter<RawDocType>,
|
|
418
|
+
projection?: ProjectionType<RawDocType> | null,
|
|
419
|
+
options?: QueryOptions<RawDocType> | null
|
|
420
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TDocOverrides>;
|
|
421
|
+
find(
|
|
422
|
+
filter?: Query<any, any>,
|
|
423
|
+
projection?: ProjectionType<RawDocType> | null,
|
|
424
|
+
options?: QueryOptions<RawDocType> | null
|
|
425
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TDocOverrides>;
|
|
426
|
+
|
|
427
|
+
/** Declares the query a findOne operation. When executed, returns the first found document. */
|
|
428
|
+
findOne(
|
|
429
|
+
filter?: QueryFilter<RawDocType>,
|
|
430
|
+
projection?: ProjectionType<RawDocType> | null,
|
|
431
|
+
options?: QueryOptions<RawDocType> | null
|
|
432
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides>;
|
|
433
|
+
findOne(
|
|
434
|
+
filter?: Query<any, any>,
|
|
435
|
+
projection?: ProjectionType<RawDocType> | null,
|
|
436
|
+
options?: QueryOptions<RawDocType> | null
|
|
437
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides>;
|
|
438
|
+
|
|
439
|
+
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
440
|
+
findOneAndDelete(
|
|
441
|
+
filter?: QueryFilter<RawDocType>,
|
|
442
|
+
options?: QueryOptions<RawDocType> | null
|
|
443
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete'>;
|
|
444
|
+
findOneAndDelete(
|
|
445
|
+
filter?: Query<any, any>,
|
|
446
|
+
options?: QueryOptions<RawDocType> | null
|
|
447
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete'>;
|
|
448
|
+
|
|
449
|
+
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
450
|
+
findOneAndUpdate(
|
|
451
|
+
filter: QueryFilter<RawDocType>,
|
|
452
|
+
update: UpdateQuery<RawDocType>,
|
|
453
|
+
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
454
|
+
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
455
|
+
findOneAndUpdate(
|
|
456
|
+
filter: Query<any, any>,
|
|
457
|
+
update: UpdateQuery<RawDocType>,
|
|
458
|
+
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
459
|
+
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
460
|
+
findOneAndUpdate(
|
|
461
|
+
filter: QueryFilter<RawDocType>,
|
|
462
|
+
update: UpdateQuery<RawDocType>,
|
|
463
|
+
options: QueryOptions<RawDocType> & { upsert: true } & ReturnsNewDoc
|
|
464
|
+
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
465
|
+
findOneAndUpdate(
|
|
466
|
+
filter: Query<any, any>,
|
|
467
|
+
update: UpdateQuery<RawDocType>,
|
|
468
|
+
options: QueryOptions<RawDocType> & { upsert: true } & ReturnsNewDoc
|
|
469
|
+
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
470
|
+
findOneAndUpdate(
|
|
471
|
+
filter?: QueryFilter<RawDocType>,
|
|
472
|
+
update?: UpdateQuery<RawDocType>,
|
|
473
|
+
options?: QueryOptions<RawDocType> | null
|
|
474
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
475
|
+
findOneAndUpdate(
|
|
476
|
+
filter?: Query<any, any>,
|
|
477
|
+
update?: UpdateQuery<RawDocType>,
|
|
478
|
+
options?: QueryOptions<RawDocType> | null
|
|
479
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
480
|
+
|
|
481
|
+
/** Declares the query a findById operation. When executed, returns the document with the given `_id`. */
|
|
482
|
+
findById(
|
|
483
|
+
id: mongodb.ObjectId | any,
|
|
484
|
+
projection?: ProjectionType<RawDocType> | null,
|
|
485
|
+
options?: QueryOptions<RawDocType> | null
|
|
486
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TDocOverrides>;
|
|
487
|
+
|
|
488
|
+
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
489
|
+
findByIdAndDelete(
|
|
490
|
+
id: mongodb.ObjectId | any,
|
|
491
|
+
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
492
|
+
): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides>;
|
|
493
|
+
findByIdAndDelete(
|
|
494
|
+
id?: mongodb.ObjectId | any,
|
|
495
|
+
options?: QueryOptions<RawDocType> | null
|
|
496
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete', TDocOverrides>;
|
|
497
|
+
|
|
498
|
+
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
499
|
+
findByIdAndUpdate(
|
|
500
|
+
id: mongodb.ObjectId | any,
|
|
501
|
+
update: UpdateQuery<RawDocType>,
|
|
502
|
+
options: QueryOptions<RawDocType> & { includeResultMetadata: true }
|
|
503
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
504
|
+
findByIdAndUpdate(
|
|
505
|
+
id: mongodb.ObjectId | any,
|
|
506
|
+
update: UpdateQuery<RawDocType>,
|
|
507
|
+
options: QueryOptions<RawDocType> & { upsert: true } & ReturnsNewDoc
|
|
508
|
+
): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
509
|
+
findByIdAndUpdate(
|
|
510
|
+
id?: mongodb.ObjectId | any,
|
|
511
|
+
update?: UpdateQuery<RawDocType>,
|
|
512
|
+
options?: QueryOptions<RawDocType> | null
|
|
513
|
+
): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TDocOverrides>;
|
|
514
|
+
|
|
515
|
+
/** Specifies a `$geometry` condition */
|
|
516
|
+
geometry(object: { type: string, coordinates: any[] }): this;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* For update operations, returns the value of a path in the update's `$set`.
|
|
520
|
+
* Useful for writing getters/setters that can work with both update operations
|
|
521
|
+
* and `save()`.
|
|
522
|
+
*/
|
|
523
|
+
get(path: string): any;
|
|
524
|
+
|
|
525
|
+
/** Returns the current query filter (also known as conditions) as a POJO. */
|
|
526
|
+
getFilter(): QueryFilter<RawDocType>;
|
|
527
|
+
|
|
528
|
+
/** Gets query options. */
|
|
529
|
+
getOptions(): QueryOptions<RawDocType>;
|
|
530
|
+
|
|
531
|
+
/** Gets a list of paths to be populated by this query */
|
|
532
|
+
getPopulatedPaths(): Array<string>;
|
|
533
|
+
|
|
534
|
+
/** Returns the current query filter. Equivalent to `getFilter()`. */
|
|
535
|
+
getQuery(): QueryFilter<RawDocType>;
|
|
536
|
+
|
|
537
|
+
/** Returns the current update operations as a JSON object. */
|
|
538
|
+
getUpdate(): UpdateQuery<DocType> | UpdateWithAggregationPipeline | null;
|
|
539
|
+
|
|
540
|
+
/** Specifies a `$gt` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
541
|
+
gt(path: string, val: any): this;
|
|
542
|
+
gt(val: number): this;
|
|
543
|
+
|
|
544
|
+
/** Specifies a `$gte` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
545
|
+
gte(path: string, val: any): this;
|
|
546
|
+
gte(val: number): this;
|
|
547
|
+
|
|
548
|
+
/** Sets query hints. */
|
|
549
|
+
hint(val: any): this;
|
|
550
|
+
|
|
551
|
+
/** Specifies an `$in` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
552
|
+
in(path: string, val: any[]): this;
|
|
553
|
+
in(val: Array<any>): this;
|
|
554
|
+
|
|
555
|
+
/** Declares an intersects query for `geometry()`. */
|
|
556
|
+
intersects(arg?: any): this;
|
|
557
|
+
|
|
558
|
+
/** Requests acknowledgement that this operation has been persisted to MongoDB's on-disk journal. */
|
|
559
|
+
j(val: boolean | null): this;
|
|
560
|
+
|
|
561
|
+
/** Sets the lean option. */
|
|
562
|
+
lean(): QueryWithHelpers<
|
|
563
|
+
ResultType extends null
|
|
564
|
+
? GetLeanResultType<RawDocType, ResultType, QueryOp> | null
|
|
565
|
+
: GetLeanResultType<RawDocType, ResultType, QueryOp>,
|
|
566
|
+
DocType,
|
|
567
|
+
THelpers,
|
|
568
|
+
RawDocType,
|
|
569
|
+
QueryOp,
|
|
570
|
+
TDocOverrides
|
|
571
|
+
>;
|
|
572
|
+
lean(
|
|
573
|
+
val: true | LeanOptions
|
|
574
|
+
): QueryWithHelpers<
|
|
575
|
+
ResultType extends null
|
|
576
|
+
? GetLeanResultType<RawDocType, ResultType, QueryOp> | null
|
|
577
|
+
: GetLeanResultType<RawDocType, ResultType, QueryOp>,
|
|
578
|
+
DocType,
|
|
579
|
+
THelpers,
|
|
580
|
+
RawDocType,
|
|
581
|
+
QueryOp,
|
|
582
|
+
TDocOverrides
|
|
583
|
+
>;
|
|
584
|
+
lean(
|
|
585
|
+
val: false
|
|
586
|
+
): QueryWithHelpers<
|
|
587
|
+
ResultType extends AnyArray<any>
|
|
588
|
+
? DocType[]
|
|
589
|
+
: ResultType extends null
|
|
590
|
+
? DocType | null
|
|
591
|
+
: DocType,
|
|
592
|
+
DocType,
|
|
593
|
+
THelpers,
|
|
594
|
+
RawDocType,
|
|
595
|
+
QueryOp,
|
|
596
|
+
TDocOverrides
|
|
597
|
+
>;
|
|
598
|
+
lean<LeanResultType = RawDocType>(): QueryWithHelpers<
|
|
599
|
+
ResultType extends null
|
|
600
|
+
? LeanResultType | null
|
|
601
|
+
: LeanResultType,
|
|
602
|
+
DocType,
|
|
603
|
+
THelpers,
|
|
604
|
+
RawDocType,
|
|
605
|
+
QueryOp,
|
|
606
|
+
TDocOverrides
|
|
607
|
+
>;
|
|
608
|
+
lean<LeanResultType = RawDocType>(
|
|
609
|
+
val: boolean | LeanOptions
|
|
610
|
+
): QueryWithHelpers<
|
|
611
|
+
ResultType extends null
|
|
612
|
+
? LeanResultType | null
|
|
613
|
+
: LeanResultType,
|
|
614
|
+
DocType,
|
|
615
|
+
THelpers,
|
|
616
|
+
RawDocType,
|
|
617
|
+
QueryOp,
|
|
618
|
+
TDocOverrides
|
|
619
|
+
>;
|
|
620
|
+
|
|
621
|
+
/** Specifies the maximum number of documents the query will return. */
|
|
622
|
+
limit(val: number): this;
|
|
623
|
+
|
|
624
|
+
/** Specifies a `$lt` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
625
|
+
lt(path: string, val: any): this;
|
|
626
|
+
lt(val: number): this;
|
|
627
|
+
|
|
628
|
+
/** Specifies a `$lte` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
629
|
+
lte(path: string, val: any): this;
|
|
630
|
+
lte(val: number): this;
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Runs a function `fn` and treats the return value of `fn` as the new value
|
|
634
|
+
* for the query to resolve to.
|
|
635
|
+
*/
|
|
636
|
+
transform<MappedType>(fn: (doc: ResultType) => MappedType): QueryWithHelpers<MappedType, DocType, THelpers, RawDocType, QueryOp, TDocOverrides>;
|
|
637
|
+
|
|
638
|
+
/** Specifies an `$maxDistance` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
639
|
+
maxDistance(path: string, val: number): this;
|
|
640
|
+
maxDistance(val: number): this;
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Sets the [maxTimeMS](https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/)
|
|
644
|
+
* option. This will tell the MongoDB server to abort if the query or write op
|
|
645
|
+
* has been running for more than `ms` milliseconds.
|
|
646
|
+
*/
|
|
647
|
+
maxTimeMS(ms: number): this;
|
|
648
|
+
|
|
649
|
+
/** Merges another Query or conditions object into this one. */
|
|
650
|
+
merge(source: QueryFilter<RawDocType>): this;
|
|
651
|
+
merge(source: Query<any, any>): this;
|
|
652
|
+
|
|
653
|
+
/** Specifies a `$mod` condition, filters documents for documents whose `path` property is a number that is equal to `remainder` modulo `divisor`. */
|
|
654
|
+
mod(path: string, val: number): this;
|
|
655
|
+
mod(val: Array<number>): this;
|
|
656
|
+
|
|
657
|
+
/** The model this query was created from */
|
|
658
|
+
model: Model<any>; // Can't use DocType, causes "Type instantiation is excessively deep"
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Getter/setter around the current mongoose-specific options for this query
|
|
662
|
+
* Below are the current Mongoose-specific options.
|
|
663
|
+
*/
|
|
664
|
+
mongooseOptions(val?: QueryOptions<RawDocType>): QueryOptions<RawDocType>;
|
|
665
|
+
|
|
666
|
+
/** Specifies a `$ne` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
667
|
+
ne(path: string, val: any): this;
|
|
668
|
+
ne(val: any): this;
|
|
669
|
+
|
|
670
|
+
/** Specifies a `$near` or `$nearSphere` condition */
|
|
671
|
+
near(path: string, val: any): this;
|
|
672
|
+
near(val: any): this;
|
|
673
|
+
|
|
674
|
+
/** Specifies an `$nin` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
675
|
+
nin(path: string, val: any[]): this;
|
|
676
|
+
nin(val: Array<any>): this;
|
|
677
|
+
|
|
678
|
+
/** Specifies arguments for an `$nor` condition. */
|
|
679
|
+
nor(array: Array<QueryFilter<RawDocType>>): this;
|
|
680
|
+
|
|
681
|
+
/** Specifies arguments for an `$or` condition. */
|
|
682
|
+
or(array: Array<QueryFilter<RawDocType>>): this;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Make this query throw an error if no documents match the given `filter`.
|
|
686
|
+
* This is handy for integrating with async/await, because `orFail()` saves you
|
|
687
|
+
* an extra `if` statement to check if no document was found.
|
|
688
|
+
*/
|
|
689
|
+
orFail(err?: NativeError | (() => NativeError)): QueryWithHelpers<NonNullable<ResultType>, DocType, THelpers, RawDocType, QueryOp, TDocOverrides>;
|
|
690
|
+
|
|
691
|
+
/** Specifies a `$polygon` condition */
|
|
692
|
+
polygon(path: string, ...coordinatePairs: number[][]): this;
|
|
693
|
+
polygon(...coordinatePairs: number[][]): this;
|
|
694
|
+
|
|
695
|
+
/** Specifies paths which should be populated with other documents. */
|
|
696
|
+
populate(
|
|
697
|
+
path: string | string[],
|
|
698
|
+
select?: string | any,
|
|
699
|
+
model?: string | Model<any, THelpers>,
|
|
700
|
+
match?: any
|
|
701
|
+
): QueryWithHelpers<
|
|
702
|
+
ResultType,
|
|
703
|
+
DocType,
|
|
704
|
+
THelpers,
|
|
705
|
+
RawDocType,
|
|
706
|
+
QueryOp,
|
|
707
|
+
TDocOverrides
|
|
708
|
+
>;
|
|
709
|
+
populate(
|
|
710
|
+
options: PopulateOptions | (PopulateOptions | string)[]
|
|
711
|
+
): QueryWithHelpers<
|
|
712
|
+
ResultType,
|
|
713
|
+
DocType,
|
|
714
|
+
THelpers,
|
|
715
|
+
RawDocType,
|
|
716
|
+
QueryOp,
|
|
717
|
+
TDocOverrides
|
|
718
|
+
>;
|
|
719
|
+
populate<Paths>(
|
|
720
|
+
path: string | string[],
|
|
721
|
+
select?: string | any,
|
|
722
|
+
model?: string | Model<any, THelpers>,
|
|
723
|
+
match?: any
|
|
724
|
+
): QueryWithHelpers<
|
|
725
|
+
MergePopulatePaths<RawDocType, ResultType, QueryOp, Paths, THelpers, TDocOverrides>,
|
|
726
|
+
DocType,
|
|
727
|
+
THelpers,
|
|
728
|
+
UnpackedIntersection<RawDocType, Paths>,
|
|
729
|
+
QueryOp,
|
|
730
|
+
TDocOverrides
|
|
731
|
+
>;
|
|
732
|
+
populate<Paths>(
|
|
733
|
+
options: PopulateOptions | (PopulateOptions | string)[]
|
|
734
|
+
): QueryWithHelpers<
|
|
735
|
+
MergePopulatePaths<RawDocType, ResultType, QueryOp, Paths, THelpers, TDocOverrides>,
|
|
736
|
+
DocType,
|
|
737
|
+
THelpers,
|
|
738
|
+
UnpackedIntersection<RawDocType, Paths>,
|
|
739
|
+
QueryOp,
|
|
740
|
+
TDocOverrides
|
|
741
|
+
>;
|
|
742
|
+
|
|
743
|
+
/** Add pre middleware to this query instance. Doesn't affect other queries. */
|
|
744
|
+
pre(fn: Function): this;
|
|
745
|
+
|
|
746
|
+
/** Add post middleware to this query instance. Doesn't affect other queries. */
|
|
747
|
+
post(fn: Function): this;
|
|
748
|
+
|
|
749
|
+
/** Get/set the current projection (AKA fields). Pass `null` to remove the current projection. */
|
|
750
|
+
projection(fields?: ProjectionFields<DocType> | string): ProjectionFields<DocType>;
|
|
751
|
+
projection(fields: null): null;
|
|
752
|
+
projection(): ProjectionFields<DocType> | null;
|
|
753
|
+
|
|
754
|
+
/** Determines the MongoDB nodes from which to read. */
|
|
755
|
+
read(mode: string | mongodb.ReadPreferenceMode, tags?: any[]): this;
|
|
756
|
+
|
|
757
|
+
/** Sets the readConcern option for the query. */
|
|
758
|
+
readConcern(level: string): this;
|
|
759
|
+
|
|
760
|
+
/** Specifies a `$regex` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
761
|
+
regex(path: string, val: RegExp): this;
|
|
762
|
+
regex(val: string | RegExp): this;
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Declare and/or execute this query as a replaceOne() operation. Same as
|
|
766
|
+
* `update()`, except MongoDB will replace the existing document and will
|
|
767
|
+
* not accept any [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.)
|
|
768
|
+
*/
|
|
769
|
+
replaceOne(
|
|
770
|
+
filter?: QueryFilter<RawDocType>,
|
|
771
|
+
replacement?: DocType | AnyObject,
|
|
772
|
+
options?: QueryOptions<RawDocType> | null
|
|
773
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne', TDocOverrides>;
|
|
774
|
+
replaceOne(
|
|
775
|
+
filter?: Query<any, any>,
|
|
776
|
+
replacement?: DocType | AnyObject,
|
|
777
|
+
options?: QueryOptions<RawDocType> | null
|
|
778
|
+
): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne', TDocOverrides>;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Sets this query's `sanitizeProjection` option. With `sanitizeProjection()`, you can pass potentially untrusted user data to `.select()`.
|
|
782
|
+
*/
|
|
783
|
+
sanitizeProjection(value: boolean): this;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Enable or disable schema level projections for this query. Enabled by default.
|
|
787
|
+
* Set to `false` to include fields with `select: false` in the query result by default.
|
|
788
|
+
*/
|
|
789
|
+
schemaLevelProjections(value: boolean): this;
|
|
790
|
+
|
|
791
|
+
/** Specifies which document fields to include or exclude (also known as the query "projection") */
|
|
792
|
+
select<RawDocTypeOverride extends { [P in keyof RawDocType]?: any } = {}>(
|
|
793
|
+
arg: string | readonly string[] | Record<string, number | boolean | string | object>
|
|
794
|
+
): QueryWithHelpers<
|
|
795
|
+
IfEquals<
|
|
796
|
+
RawDocTypeOverride,
|
|
797
|
+
{},
|
|
798
|
+
ResultType,
|
|
799
|
+
ResultType extends any[]
|
|
800
|
+
? ResultType extends HydratedDocument<any>[]
|
|
801
|
+
? HydratedDocument<RawDocTypeOverride>[]
|
|
802
|
+
: RawDocTypeOverride[]
|
|
803
|
+
: (ResultType extends HydratedDocument<any>
|
|
804
|
+
? HydratedDocument<RawDocTypeOverride>
|
|
805
|
+
: RawDocTypeOverride) | (null extends ResultType ? null : never)
|
|
806
|
+
>,
|
|
807
|
+
DocType,
|
|
808
|
+
THelpers,
|
|
809
|
+
IfEquals<
|
|
810
|
+
RawDocTypeOverride,
|
|
811
|
+
{},
|
|
812
|
+
RawDocType,
|
|
813
|
+
RawDocTypeOverride
|
|
814
|
+
>,
|
|
815
|
+
QueryOp,
|
|
816
|
+
TDocOverrides
|
|
817
|
+
>;
|
|
818
|
+
|
|
819
|
+
/** Determines if field selection has been made. */
|
|
820
|
+
selected(): boolean;
|
|
821
|
+
|
|
822
|
+
/** Determines if exclusive field selection has been made. */
|
|
823
|
+
selectedExclusively(): boolean;
|
|
824
|
+
|
|
825
|
+
/** Determines if inclusive field selection has been made. */
|
|
826
|
+
selectedInclusively(): boolean;
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Sets the [MongoDB session](https://www.mongodb.com/docs/manual/reference/server-sessions/)
|
|
830
|
+
* associated with this query. Sessions are how you mark a query as part of a
|
|
831
|
+
* [transaction](/docs/transactions.html).
|
|
832
|
+
*/
|
|
833
|
+
session(session: mongodb.ClientSession | null): this;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Adds a `$set` to this query's update without changing the operation.
|
|
837
|
+
* This is useful for query middleware so you can add an update regardless
|
|
838
|
+
* of whether you use `updateOne()`, `updateMany()`, `findOneAndUpdate()`, etc.
|
|
839
|
+
*/
|
|
840
|
+
set(path: string | Record<string, unknown>, value?: any): this;
|
|
841
|
+
|
|
842
|
+
/** Sets query options. Some options only make sense for certain operations. */
|
|
843
|
+
setOptions(options: QueryOptions<RawDocType>, overwrite?: boolean): this;
|
|
844
|
+
|
|
845
|
+
/** Sets the query conditions to the provided JSON object. */
|
|
846
|
+
setQuery(val: QueryFilter<RawDocType> | null): void;
|
|
847
|
+
setQuery(val: Query<any, any> | null): void;
|
|
848
|
+
|
|
849
|
+
setUpdate(update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline): void;
|
|
850
|
+
|
|
851
|
+
/** Specifies an `$size` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
852
|
+
size(path: string, val: number): this;
|
|
853
|
+
size(val: number): this;
|
|
854
|
+
|
|
855
|
+
/** Specifies the number of documents to skip. */
|
|
856
|
+
skip(val: number): this;
|
|
857
|
+
|
|
858
|
+
/** Specifies a `$slice` projection for an array. */
|
|
859
|
+
slice(path: string, val: number | Array<number>): this;
|
|
860
|
+
slice(val: number | Array<number>): this;
|
|
861
|
+
|
|
862
|
+
/** Sets the sort order. If an object is passed, values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`. */
|
|
863
|
+
sort(
|
|
864
|
+
arg?: string | Record<string, SortOrder | { $meta: any }> | [string, SortOrder][] | undefined | null,
|
|
865
|
+
options?: { override?: boolean }
|
|
866
|
+
): this;
|
|
867
|
+
|
|
868
|
+
/** Sets the tailable option (for use with capped collections). */
|
|
869
|
+
tailable(bool?: boolean, opts?: {
|
|
870
|
+
numberOfRetries?: number;
|
|
871
|
+
tailableRetryInterval?: number;
|
|
872
|
+
}): this;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Executes the query returning a `Promise` which will be
|
|
876
|
+
* resolved with either the doc(s) or rejected with the error.
|
|
877
|
+
*/
|
|
878
|
+
then: Promise<ResultType>['then'];
|
|
879
|
+
|
|
880
|
+
/** Converts this query to a customized, reusable query constructor with all arguments and options retained. */
|
|
881
|
+
toConstructor<RetType = typeof Query>(): RetType;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Declare and/or execute this query as an updateMany() operation. Same as
|
|
885
|
+
* `update()`, except MongoDB will update _all_ documents that match `filter`
|
|
886
|
+
*/
|
|
887
|
+
updateMany(
|
|
888
|
+
filter: QueryFilter<RawDocType>,
|
|
889
|
+
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
890
|
+
options?: QueryOptions<RawDocType> | null
|
|
891
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany', TDocOverrides>;
|
|
892
|
+
updateMany(
|
|
893
|
+
filter: Query<any, any>,
|
|
894
|
+
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
895
|
+
options?: QueryOptions<RawDocType> | null
|
|
896
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany', TDocOverrides>;
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Declare and/or execute this query as an updateOne() operation. Same as
|
|
900
|
+
* `update()`, except it does not support the `multi` or `overwrite` options.
|
|
901
|
+
*/
|
|
902
|
+
updateOne(
|
|
903
|
+
filter: QueryFilter<RawDocType>,
|
|
904
|
+
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
905
|
+
options?: QueryOptions<RawDocType> | null
|
|
906
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne', TDocOverrides>;
|
|
907
|
+
updateOne(
|
|
908
|
+
filter: Query<any, any>,
|
|
909
|
+
update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
|
910
|
+
options?: QueryOptions<RawDocType> | null
|
|
911
|
+
): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne', TDocOverrides>;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Sets the specified number of `mongod` servers, or tag set of `mongod` servers,
|
|
915
|
+
* that must acknowledge this write before this write is considered successful.
|
|
916
|
+
*/
|
|
917
|
+
w(val: string | number | null): this;
|
|
918
|
+
|
|
919
|
+
/** Specifies a path for use with chaining. */
|
|
920
|
+
where(path: string, val?: any): this;
|
|
921
|
+
where(obj: object): this;
|
|
922
|
+
where(): this;
|
|
923
|
+
|
|
924
|
+
/** Defines a `$within` or `$geoWithin` argument for geo-spatial queries. */
|
|
925
|
+
within(val?: any): this;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* If [`w > 1`](/docs/api/query.html#query_Query-w), the maximum amount of time to
|
|
929
|
+
* wait for this write to propagate through the replica set before this
|
|
930
|
+
* operation fails. The default is `0`, which means no timeout.
|
|
931
|
+
*/
|
|
932
|
+
wtimeout(ms: number): this;
|
|
933
|
+
}
|
|
934
|
+
}
|