@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
|
@@ -0,0 +1,1306 @@
|
|
|
1
|
+
declare module 'mongoose' {
|
|
2
|
+
import mongodb = require('mongodb');
|
|
3
|
+
|
|
4
|
+
export interface DiscriminatorOptions {
|
|
5
|
+
value?: string | number | ObjectId;
|
|
6
|
+
clone?: boolean;
|
|
7
|
+
overwriteModels?: boolean;
|
|
8
|
+
mergeHooks?: boolean;
|
|
9
|
+
mergePlugins?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AcceptsDiscriminator {
|
|
13
|
+
/** Adds a discriminator type. */
|
|
14
|
+
discriminator<D>(
|
|
15
|
+
name: string | number,
|
|
16
|
+
schema: Schema,
|
|
17
|
+
value?: string | number | ObjectId | DiscriminatorOptions
|
|
18
|
+
): Model<D>;
|
|
19
|
+
discriminator<T, U>(
|
|
20
|
+
name: string | number,
|
|
21
|
+
schema: Schema<T, U>,
|
|
22
|
+
value?: string | number | ObjectId | DiscriminatorOptions
|
|
23
|
+
): Model<U>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type MongooseBulkWriteResult = mongodb.BulkWriteResult & {
|
|
27
|
+
mongoose?: {
|
|
28
|
+
validationErrors: Error[],
|
|
29
|
+
results: Array<Error | mongodb.WriteError | null>
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export interface MongooseBulkWriteOptions extends mongodb.BulkWriteOptions {
|
|
34
|
+
session?: ClientSession;
|
|
35
|
+
skipValidation?: boolean;
|
|
36
|
+
throwOnValidationError?: boolean;
|
|
37
|
+
strict?: boolean | 'throw';
|
|
38
|
+
/** When false, do not add timestamps to documents. Can be overridden at the operation level. */
|
|
39
|
+
timestamps?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface MongooseBulkSaveOptions extends mongodb.BulkWriteOptions {
|
|
43
|
+
timestamps?: boolean;
|
|
44
|
+
session?: ClientSession;
|
|
45
|
+
validateBeforeSave?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated use AnyBulkWriteOperation instead
|
|
50
|
+
*/
|
|
51
|
+
interface MongooseBulkWritePerWriteOptions {
|
|
52
|
+
timestamps?: boolean;
|
|
53
|
+
strict?: boolean | 'throw';
|
|
54
|
+
session?: ClientSession;
|
|
55
|
+
skipValidation?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface HydrateOptions {
|
|
59
|
+
setters?: boolean;
|
|
60
|
+
hydratedPopulatedDocs?: boolean;
|
|
61
|
+
virtuals?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface InsertManyOptions extends
|
|
65
|
+
PopulateOption,
|
|
66
|
+
SessionOption {
|
|
67
|
+
limit?: number;
|
|
68
|
+
// @deprecated, use includeResultMetadata instead
|
|
69
|
+
rawResult?: boolean;
|
|
70
|
+
includeResultMetadata?: boolean;
|
|
71
|
+
ordered?: boolean;
|
|
72
|
+
lean?: boolean;
|
|
73
|
+
throwOnValidationError?: boolean;
|
|
74
|
+
timestamps?: boolean | QueryTimestampsConfig;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface InsertManyResult<T> extends mongodb.InsertManyResult<T> {
|
|
78
|
+
mongoose?: { validationErrors?: Array<Error.CastError | Error.ValidatorError> };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type UpdateWriteOpResult = mongodb.UpdateResult;
|
|
82
|
+
type UpdateResult = mongodb.UpdateResult;
|
|
83
|
+
type DeleteResult = mongodb.DeleteResult;
|
|
84
|
+
|
|
85
|
+
interface MapReduceOptions<T, K, R> {
|
|
86
|
+
map: Function | string;
|
|
87
|
+
reduce: (key: K, vals: T[]) => R;
|
|
88
|
+
/** query filter object. */
|
|
89
|
+
query?: any;
|
|
90
|
+
/** sort input objects using this key */
|
|
91
|
+
sort?: any;
|
|
92
|
+
/** max number of documents */
|
|
93
|
+
limit?: number;
|
|
94
|
+
/** keep temporary data default: false */
|
|
95
|
+
keeptemp?: boolean;
|
|
96
|
+
/** finalize function */
|
|
97
|
+
finalize?: (key: K, val: R) => R;
|
|
98
|
+
/** scope variables exposed to map/reduce/finalize during execution */
|
|
99
|
+
scope?: any;
|
|
100
|
+
/** it is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X default: false */
|
|
101
|
+
jsMode?: boolean;
|
|
102
|
+
/** provide statistics on job execution time. default: false */
|
|
103
|
+
verbose?: boolean;
|
|
104
|
+
readPreference?: string;
|
|
105
|
+
/** sets the output target for the map reduce job. default: {inline: 1} */
|
|
106
|
+
out?: {
|
|
107
|
+
/** the results are returned in an array */
|
|
108
|
+
inline?: number;
|
|
109
|
+
/**
|
|
110
|
+
* {replace: 'collectionName'} add the results to collectionName: the
|
|
111
|
+
* results replace the collection
|
|
112
|
+
*/
|
|
113
|
+
replace?: string;
|
|
114
|
+
/**
|
|
115
|
+
* {reduce: 'collectionName'} add the results to collectionName: if
|
|
116
|
+
* dups are detected, uses the reducer / finalize functions
|
|
117
|
+
*/
|
|
118
|
+
reduce?: string;
|
|
119
|
+
/**
|
|
120
|
+
* {merge: 'collectionName'} add the results to collectionName: if
|
|
121
|
+
* dups exist the new docs overwrite the old
|
|
122
|
+
*/
|
|
123
|
+
merge?: string;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface GeoSearchOptions {
|
|
128
|
+
/** x,y point to search for */
|
|
129
|
+
near: number[];
|
|
130
|
+
/** the maximum distance from the point near that a result can be */
|
|
131
|
+
maxDistance: number;
|
|
132
|
+
/** The maximum number of results to return */
|
|
133
|
+
limit?: number;
|
|
134
|
+
/** return the raw object instead of the Mongoose Model */
|
|
135
|
+
lean?: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
interface ModifyResult<T> {
|
|
139
|
+
value: Default__v<Require_id<T>> | null;
|
|
140
|
+
/** see https://www.mongodb.com/docs/manual/reference/command/findAndModify/#lasterrorobject */
|
|
141
|
+
lastErrorObject?: {
|
|
142
|
+
updatedExisting?: boolean;
|
|
143
|
+
upserted?: mongodb.ObjectId;
|
|
144
|
+
};
|
|
145
|
+
ok: 0 | 1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type WriteConcern = mongodb.WriteConcern;
|
|
149
|
+
|
|
150
|
+
/** A list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list. */
|
|
151
|
+
type PathsToValidate = string[] | string;
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated
|
|
154
|
+
*/
|
|
155
|
+
type pathsToValidate = PathsToValidate;
|
|
156
|
+
|
|
157
|
+
interface SaveOptions extends
|
|
158
|
+
SessionOption {
|
|
159
|
+
checkKeys?: boolean;
|
|
160
|
+
j?: boolean;
|
|
161
|
+
safe?: boolean | WriteConcern;
|
|
162
|
+
timestamps?: boolean | QueryTimestampsConfig;
|
|
163
|
+
validateBeforeSave?: boolean;
|
|
164
|
+
validateModifiedOnly?: boolean;
|
|
165
|
+
w?: number | string;
|
|
166
|
+
wtimeout?: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface CreateOptions extends SaveOptions {
|
|
170
|
+
ordered?: boolean;
|
|
171
|
+
aggregateErrors?: boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
interface RemoveOptions extends SessionOption, Omit<mongodb.DeleteOptions, 'session'> {}
|
|
175
|
+
|
|
176
|
+
interface MongooseBulkWritePerOperationOptions {
|
|
177
|
+
/** Skip validation for this operation. */
|
|
178
|
+
skipValidation?: boolean;
|
|
179
|
+
/** When false, do not add timestamps. When true, overrides the `timestamps` option set in the `bulkWrite` options. */
|
|
180
|
+
timestamps?: boolean;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface MongooseBulkUpdatePerOperationOptions extends MongooseBulkWritePerOperationOptions {
|
|
184
|
+
/** When true, allows updating fields that are marked as `immutable` in the schema. */
|
|
185
|
+
overwriteImmutable?: boolean;
|
|
186
|
+
/** When false, do not set default values on insert. */
|
|
187
|
+
setDefaultsOnInsert?: boolean;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export type InsertOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
191
|
+
mongodb.InsertOneModel<TSchema> & MongooseBulkWritePerOperationOptions;
|
|
192
|
+
|
|
193
|
+
export type ReplaceOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
194
|
+
Omit<mongodb.ReplaceOneModel<TSchema>, 'filter'> &
|
|
195
|
+
{ filter: QueryFilter<TSchema> } &
|
|
196
|
+
MongooseBulkUpdatePerOperationOptions;
|
|
197
|
+
|
|
198
|
+
export type UpdateOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
199
|
+
Omit<mongodb.UpdateOneModel<TSchema>, 'filter'> &
|
|
200
|
+
{ filter: QueryFilter<TSchema> } &
|
|
201
|
+
MongooseBulkUpdatePerOperationOptions;
|
|
202
|
+
|
|
203
|
+
export type UpdateManyModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
204
|
+
Omit<mongodb.UpdateManyModel<TSchema>, 'filter'> &
|
|
205
|
+
{ filter: QueryFilter<TSchema> } &
|
|
206
|
+
MongooseBulkUpdatePerOperationOptions;
|
|
207
|
+
|
|
208
|
+
export type DeleteOneModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
209
|
+
Omit<mongodb.DeleteOneModel<TSchema>, 'filter'> &
|
|
210
|
+
{ filter: QueryFilter<TSchema> };
|
|
211
|
+
|
|
212
|
+
export type DeleteManyModel<TSchema extends mongodb.Document = mongodb.Document> =
|
|
213
|
+
Omit<mongodb.DeleteManyModel<TSchema>, 'filter'> &
|
|
214
|
+
{ filter: QueryFilter<TSchema> };
|
|
215
|
+
|
|
216
|
+
export type AnyBulkWriteOperation<TSchema extends mongodb.Document = mongodb.Document> =
|
|
217
|
+
| { insertOne: InsertOneModel<TSchema> }
|
|
218
|
+
| { replaceOne: ReplaceOneModel<TSchema> }
|
|
219
|
+
| { updateOne: UpdateOneModel<TSchema> }
|
|
220
|
+
| { updateMany: UpdateManyModel<TSchema> }
|
|
221
|
+
| { deleteOne: DeleteOneModel<TSchema> }
|
|
222
|
+
| { deleteMany: DeleteManyModel<TSchema> };
|
|
223
|
+
|
|
224
|
+
const Model: Model<any>;
|
|
225
|
+
|
|
226
|
+
/*
|
|
227
|
+
* Apply common casting logic to the given type, allowing:
|
|
228
|
+
* - strings for ObjectIds
|
|
229
|
+
* - strings and numbers for Dates
|
|
230
|
+
* - strings for Buffers
|
|
231
|
+
* - strings for UUIDs
|
|
232
|
+
* - POJOs for subdocuments
|
|
233
|
+
* - vanilla arrays of POJOs for document arrays
|
|
234
|
+
* - POJOs and array of arrays for maps
|
|
235
|
+
*/
|
|
236
|
+
type ApplyBasicCreateCasting<T> = {
|
|
237
|
+
[K in keyof T]: NonNullable<T[K]> extends Map<infer KeyType extends string, infer ValueType>
|
|
238
|
+
? (Record<KeyType, ValueType> | Array<[KeyType, ValueType]> | T[K])
|
|
239
|
+
: NonNullable<T[K]> extends Types.DocumentArray<infer RawSubdocType>
|
|
240
|
+
? RawSubdocType[] | T[K]
|
|
241
|
+
: NonNullable<T[K]> extends Document<any, any, infer RawSubdocType>
|
|
242
|
+
? ApplyBasicCreateCasting<RawSubdocType> | T[K]
|
|
243
|
+
: NonNullable<T[K]> extends Record<string, any>
|
|
244
|
+
? ApplyBasicCreateCasting<T[K]> | T[K]
|
|
245
|
+
: QueryTypeCasting<T[K]>;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
type HasLeanOption<TSchema> = 'lean' extends keyof ObtainSchemaGeneric<TSchema, 'TSchemaOptions'> ?
|
|
249
|
+
ObtainSchemaGeneric<TSchema, 'TSchemaOptions'>['lean'] extends Record<string, any> ?
|
|
250
|
+
true :
|
|
251
|
+
ObtainSchemaGeneric<TSchema, 'TSchemaOptions'>['lean'] :
|
|
252
|
+
false;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Models are fancy constructors compiled from `Schema` definitions.
|
|
256
|
+
* An instance of a model is called a document.
|
|
257
|
+
* Models are responsible for creating and reading documents from the underlying MongoDB database
|
|
258
|
+
*/
|
|
259
|
+
export interface Model<
|
|
260
|
+
TRawDocType,
|
|
261
|
+
TQueryHelpers = {},
|
|
262
|
+
TInstanceMethods = {},
|
|
263
|
+
TVirtuals = {},
|
|
264
|
+
THydratedDocumentType = HydratedDocument<TRawDocType, TVirtuals & TInstanceMethods, TQueryHelpers, TVirtuals>,
|
|
265
|
+
TSchema = any,
|
|
266
|
+
TLeanResultType = TRawDocType> extends
|
|
267
|
+
NodeJS.EventEmitter,
|
|
268
|
+
IndexManager,
|
|
269
|
+
SessionStarter {
|
|
270
|
+
new <DocType = Partial<TRawDocType>>(doc?: DocType, fields?: any | null, options?: AnyObject): THydratedDocumentType;
|
|
271
|
+
|
|
272
|
+
aggregate<R = any>(pipeline?: PipelineStage[], options?: AggregateOptions): Aggregate<Array<R>>;
|
|
273
|
+
aggregate<R = any>(pipeline: PipelineStage[]): Aggregate<Array<R>>;
|
|
274
|
+
|
|
275
|
+
/** Base Mongoose instance the model uses. */
|
|
276
|
+
base: Mongoose;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* If this is a discriminator model, `baseModelName` is the name of
|
|
280
|
+
* the base model.
|
|
281
|
+
*/
|
|
282
|
+
baseModelName: string | undefined;
|
|
283
|
+
|
|
284
|
+
/* Cast the given POJO to the model's schema */
|
|
285
|
+
castObject(obj: AnyObject, options?: { ignoreCastErrors?: boolean }): TRawDocType;
|
|
286
|
+
|
|
287
|
+
/* Apply defaults to the given document or POJO. */
|
|
288
|
+
applyDefaults(obj: AnyObject): AnyObject;
|
|
289
|
+
applyDefaults(obj: TRawDocType): TRawDocType;
|
|
290
|
+
|
|
291
|
+
/* Apply virtuals to the given POJO. */
|
|
292
|
+
applyVirtuals(obj: AnyObject, virtalsToApply?: string[]): AnyObject;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Apply this model's timestamps to a given POJO, including subdocument timestamps
|
|
296
|
+
*/
|
|
297
|
+
applyTimestamps(obj: AnyObject, options?: { isUpdate?: boolean, currentTime?: () => Date }): AnyObject;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Sends multiple `insertOne`, `updateOne`, `updateMany`, `replaceOne`,
|
|
301
|
+
* `deleteOne`, and/or `deleteMany` operations to the MongoDB server in one
|
|
302
|
+
* command. This is faster than sending multiple independent operations (e.g.
|
|
303
|
+
* if you use `create()`) because with `bulkWrite()` there is only one network
|
|
304
|
+
* round trip to the MongoDB server.
|
|
305
|
+
*/
|
|
306
|
+
bulkWrite<DocContents = TRawDocType>(
|
|
307
|
+
writes: Array<AnyBulkWriteOperation<DocContents extends mongodb.Document ? DocContents : any>>,
|
|
308
|
+
options: mongodb.BulkWriteOptions & MongooseBulkWriteOptions & { ordered: false }
|
|
309
|
+
): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[] } }>;
|
|
310
|
+
bulkWrite<DocContents = TRawDocType>(
|
|
311
|
+
writes: Array<AnyBulkWriteOperation<DocContents extends mongodb.Document ? DocContents : any>>,
|
|
312
|
+
options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions
|
|
313
|
+
): Promise<mongodb.BulkWriteResult>;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Sends multiple `save()` calls in a single `bulkWrite()`. This is faster than
|
|
317
|
+
* sending multiple `save()` calls because with `bulkSave()` there is only one
|
|
318
|
+
* network round trip to the MongoDB server.
|
|
319
|
+
*/
|
|
320
|
+
bulkSave(documents: Array<Document>, options?: MongooseBulkSaveOptions): Promise<MongooseBulkWriteResult>;
|
|
321
|
+
|
|
322
|
+
/** Collection the model uses. */
|
|
323
|
+
collection: Collection;
|
|
324
|
+
|
|
325
|
+
/** Creates a `countDocuments` query: counts the number of documents that match `filter`. */
|
|
326
|
+
countDocuments(
|
|
327
|
+
filter?: QueryFilter<TRawDocType>,
|
|
328
|
+
options?: (mongodb.CountOptions & MongooseBaseQueryOptions<TRawDocType> & mongodb.Abortable) | null
|
|
329
|
+
): QueryWithHelpers<
|
|
330
|
+
number,
|
|
331
|
+
THydratedDocumentType,
|
|
332
|
+
TQueryHelpers,
|
|
333
|
+
TRawDocType,
|
|
334
|
+
'countDocuments',
|
|
335
|
+
TInstanceMethods & TVirtuals
|
|
336
|
+
>;
|
|
337
|
+
countDocuments(
|
|
338
|
+
filter?: Query<any, any>,
|
|
339
|
+
options?: (mongodb.CountOptions & MongooseBaseQueryOptions<TRawDocType> & mongodb.Abortable) | null
|
|
340
|
+
): QueryWithHelpers<
|
|
341
|
+
number,
|
|
342
|
+
THydratedDocumentType,
|
|
343
|
+
TQueryHelpers,
|
|
344
|
+
TRawDocType,
|
|
345
|
+
'countDocuments',
|
|
346
|
+
TInstanceMethods & TVirtuals
|
|
347
|
+
>;
|
|
348
|
+
|
|
349
|
+
/** Creates a new document or documents */
|
|
350
|
+
create(): Promise<null>;
|
|
351
|
+
create(doc: Partial<TRawDocType>): Promise<THydratedDocumentType>;
|
|
352
|
+
create(docs: Array<Partial<TRawDocType>>): Promise<THydratedDocumentType[]>;
|
|
353
|
+
create(docs: Array<DeepPartial<ApplyBasicCreateCasting<Require_id<TRawDocType>>>>, options: CreateOptions & { aggregateErrors: true }): Promise<(THydratedDocumentType | Error)[]>;
|
|
354
|
+
create(docs: Array<DeepPartial<ApplyBasicCreateCasting<Require_id<TRawDocType>>>>, options?: CreateOptions): Promise<THydratedDocumentType[]>;
|
|
355
|
+
create(doc: DeepPartial<ApplyBasicCreateCasting<Require_id<TRawDocType>>>): Promise<THydratedDocumentType>;
|
|
356
|
+
create(...docs: Array<DeepPartial<ApplyBasicCreateCasting<Require_id<TRawDocType>>>>): Promise<THydratedDocumentType[]>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Create the collection for this model. By default, if no indexes are specified,
|
|
360
|
+
* mongoose will not create the collection for the model until any documents are
|
|
361
|
+
* created. Use this method to create the collection explicitly.
|
|
362
|
+
*/
|
|
363
|
+
createCollection<T extends mongodb.Document>(options?: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'>): Promise<mongodb.Collection<T>>;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Create an [Atlas search index](https://www.mongodb.com/docs/atlas/atlas-search/create-index/).
|
|
367
|
+
* This function only works when connected to MongoDB Atlas.
|
|
368
|
+
*/
|
|
369
|
+
createSearchIndex(description: SearchIndexDescription): Promise<string>;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Creates all [Atlas search indexes](https://www.mongodb.com/docs/atlas/atlas-search/create-index/) defined in this model's schema.
|
|
373
|
+
* This function only works when connected to MongoDB Atlas.
|
|
374
|
+
*/
|
|
375
|
+
createSearchIndexes(): Promise<string[]>;
|
|
376
|
+
|
|
377
|
+
/** Connection the model uses. */
|
|
378
|
+
db: Connection;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Deletes all of the documents that match `conditions` from the collection.
|
|
382
|
+
* Behaves like `remove()`, but deletes all documents that match `conditions`
|
|
383
|
+
* regardless of the `single` option.
|
|
384
|
+
*/
|
|
385
|
+
deleteMany(
|
|
386
|
+
filter?: QueryFilter<TRawDocType>,
|
|
387
|
+
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
|
388
|
+
): QueryWithHelpers<
|
|
389
|
+
mongodb.DeleteResult,
|
|
390
|
+
THydratedDocumentType,
|
|
391
|
+
TQueryHelpers,
|
|
392
|
+
TLeanResultType,
|
|
393
|
+
'deleteMany',
|
|
394
|
+
TInstanceMethods & TVirtuals
|
|
395
|
+
>;
|
|
396
|
+
deleteMany(
|
|
397
|
+
filter?: Query<any, any>,
|
|
398
|
+
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
|
399
|
+
): QueryWithHelpers<
|
|
400
|
+
mongodb.DeleteResult,
|
|
401
|
+
THydratedDocumentType,
|
|
402
|
+
TQueryHelpers,
|
|
403
|
+
TLeanResultType,
|
|
404
|
+
'deleteMany',
|
|
405
|
+
TInstanceMethods & TVirtuals
|
|
406
|
+
>;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Deletes the first document that matches `conditions` from the collection.
|
|
410
|
+
* Behaves like `remove()`, but deletes at most one document regardless of the
|
|
411
|
+
* `single` option.
|
|
412
|
+
*/
|
|
413
|
+
deleteOne(
|
|
414
|
+
filter?: QueryFilter<TRawDocType>,
|
|
415
|
+
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
|
416
|
+
): QueryWithHelpers<
|
|
417
|
+
mongodb.DeleteResult,
|
|
418
|
+
THydratedDocumentType,
|
|
419
|
+
TQueryHelpers,
|
|
420
|
+
TLeanResultType,
|
|
421
|
+
'deleteOne',
|
|
422
|
+
TInstanceMethods & TVirtuals
|
|
423
|
+
>;
|
|
424
|
+
deleteOne(
|
|
425
|
+
filter?: Query<any, any>,
|
|
426
|
+
options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
|
427
|
+
): QueryWithHelpers<
|
|
428
|
+
mongodb.DeleteResult,
|
|
429
|
+
THydratedDocumentType,
|
|
430
|
+
TQueryHelpers,
|
|
431
|
+
TLeanResultType,
|
|
432
|
+
'deleteOne',
|
|
433
|
+
TInstanceMethods & TVirtuals
|
|
434
|
+
>;
|
|
435
|
+
|
|
436
|
+
/** Adds a discriminator type. */
|
|
437
|
+
discriminator<TDiscriminatorSchema extends Schema<any, any>>(
|
|
438
|
+
name: string | number,
|
|
439
|
+
schema: TDiscriminatorSchema,
|
|
440
|
+
value?: string | number | ObjectId | DiscriminatorOptions
|
|
441
|
+
): Model<
|
|
442
|
+
TRawDocType & InferSchemaType<TDiscriminatorSchema>,
|
|
443
|
+
TQueryHelpers & ObtainSchemaGeneric<TDiscriminatorSchema, 'TQueryHelpers'>,
|
|
444
|
+
TInstanceMethods & ObtainSchemaGeneric<TDiscriminatorSchema, 'TInstanceMethods'>,
|
|
445
|
+
TVirtuals & ObtainSchemaGeneric<TDiscriminatorSchema, 'TVirtuals'>
|
|
446
|
+
> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'> & ObtainSchemaGeneric<TDiscriminatorSchema, 'TStaticMethods'>;
|
|
447
|
+
discriminator<D>(
|
|
448
|
+
name: string | number,
|
|
449
|
+
schema: Schema,
|
|
450
|
+
value?: string | number | ObjectId | DiscriminatorOptions
|
|
451
|
+
): Model<D>;
|
|
452
|
+
discriminator<T, U>(
|
|
453
|
+
name: string | number,
|
|
454
|
+
schema: Schema<T, U>,
|
|
455
|
+
value?: string | number | ObjectId | DiscriminatorOptions
|
|
456
|
+
): U;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Delete an existing [Atlas search index](https://www.mongodb.com/docs/atlas/atlas-search/create-index/) by name.
|
|
460
|
+
* This function only works when connected to MongoDB Atlas.
|
|
461
|
+
*/
|
|
462
|
+
dropSearchIndex(name: string): Promise<void>;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Event emitter that reports any errors that occurred. Useful for global error
|
|
466
|
+
* handling.
|
|
467
|
+
*/
|
|
468
|
+
events: NodeJS.EventEmitter;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Finds a single document by its _id field. `findById(id)` is almost*
|
|
472
|
+
* equivalent to `findOne({ _id: id })`. If you want to query by a document's
|
|
473
|
+
* `_id`, use `findById()` instead of `findOne()`.
|
|
474
|
+
*/
|
|
475
|
+
findById<ResultDoc = THydratedDocumentType>(
|
|
476
|
+
id: any,
|
|
477
|
+
projection: ProjectionType<TRawDocType> | null | undefined,
|
|
478
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
479
|
+
): QueryWithHelpers<
|
|
480
|
+
TLeanResultType | null,
|
|
481
|
+
ResultDoc,
|
|
482
|
+
TQueryHelpers,
|
|
483
|
+
TLeanResultType,
|
|
484
|
+
'findOne',
|
|
485
|
+
TInstanceMethods & TVirtuals
|
|
486
|
+
>;
|
|
487
|
+
findById<ResultDoc = THydratedDocumentType>(
|
|
488
|
+
id?: any,
|
|
489
|
+
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
490
|
+
options?: QueryOptions<TRawDocType> | null
|
|
491
|
+
): QueryWithHelpers<
|
|
492
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
493
|
+
ResultDoc,
|
|
494
|
+
TQueryHelpers,
|
|
495
|
+
TLeanResultType,
|
|
496
|
+
'findOne',
|
|
497
|
+
TInstanceMethods & TVirtuals
|
|
498
|
+
>;
|
|
499
|
+
|
|
500
|
+
/** Finds one document. */
|
|
501
|
+
findOne<ResultDoc = THydratedDocumentType>(
|
|
502
|
+
filter: QueryFilter<TRawDocType>,
|
|
503
|
+
projection: ProjectionType<TRawDocType> | null | undefined,
|
|
504
|
+
options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
|
|
505
|
+
): QueryWithHelpers<
|
|
506
|
+
TLeanResultType | null,
|
|
507
|
+
ResultDoc,
|
|
508
|
+
TQueryHelpers,
|
|
509
|
+
TLeanResultType,
|
|
510
|
+
'findOne',
|
|
511
|
+
TInstanceMethods & TVirtuals
|
|
512
|
+
>;
|
|
513
|
+
findOne(
|
|
514
|
+
filter: Query<any, any>,
|
|
515
|
+
projection: ProjectionType<TRawDocType> | null | undefined,
|
|
516
|
+
options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
|
|
517
|
+
): QueryWithHelpers<
|
|
518
|
+
TLeanResultType | null,
|
|
519
|
+
THydratedDocumentType,
|
|
520
|
+
TQueryHelpers,
|
|
521
|
+
TLeanResultType,
|
|
522
|
+
'findOne',
|
|
523
|
+
TInstanceMethods & TVirtuals
|
|
524
|
+
>;
|
|
525
|
+
findOne<ResultDoc = THydratedDocumentType>(
|
|
526
|
+
filter?: QueryFilter<TRawDocType>,
|
|
527
|
+
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
528
|
+
options?: QueryOptions<TRawDocType> & mongodb.Abortable | null | undefined
|
|
529
|
+
): QueryWithHelpers<
|
|
530
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
531
|
+
ResultDoc,
|
|
532
|
+
TQueryHelpers,
|
|
533
|
+
TLeanResultType,
|
|
534
|
+
'findOne',
|
|
535
|
+
TInstanceMethods & TVirtuals
|
|
536
|
+
>;
|
|
537
|
+
findOne(
|
|
538
|
+
filter?: Query<any, any>,
|
|
539
|
+
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
540
|
+
options?: QueryOptions<TRawDocType> & mongodb.Abortable | null | undefined
|
|
541
|
+
): QueryWithHelpers<
|
|
542
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : THydratedDocumentType | null,
|
|
543
|
+
THydratedDocumentType,
|
|
544
|
+
TQueryHelpers,
|
|
545
|
+
TLeanResultType,
|
|
546
|
+
'findOne',
|
|
547
|
+
TInstanceMethods & TVirtuals
|
|
548
|
+
>;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
552
|
+
* The document returned has no paths marked as modified initially.
|
|
553
|
+
*/
|
|
554
|
+
hydrate(obj: any, projection?: ProjectionType<TRawDocType>, options?: HydrateOptions): THydratedDocumentType;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* This function is responsible for building [indexes](https://www.mongodb.com/docs/manual/indexes/),
|
|
558
|
+
* unless [`autoIndex`](http://mongoosejs.com/docs/guide.html#autoIndex) is turned off.
|
|
559
|
+
* Mongoose calls this function automatically when a model is created using
|
|
560
|
+
* [`mongoose.model()`](/docs/api/mongoose.html#mongoose_Mongoose-model) or
|
|
561
|
+
* [`connection.model()`](/docs/api/connection.html#connection_Connection-model), so you
|
|
562
|
+
* don't need to call it.
|
|
563
|
+
*/
|
|
564
|
+
init(): Promise<THydratedDocumentType>;
|
|
565
|
+
|
|
566
|
+
/** Inserts one or more new documents as a single `insertMany` call to the MongoDB server. */
|
|
567
|
+
insertMany(
|
|
568
|
+
docs: Array<TRawDocType>
|
|
569
|
+
): Promise<Array<THydratedDocumentType>>;
|
|
570
|
+
insertMany(
|
|
571
|
+
doc: Array<TRawDocType>,
|
|
572
|
+
options: InsertManyOptions & { ordered: false; rawResult: true; }
|
|
573
|
+
): Promise<mongodb.InsertManyResult<Require_id<TRawDocType>> & {
|
|
574
|
+
mongoose: {
|
|
575
|
+
validationErrors: (CastError | Error.ValidatorError)[];
|
|
576
|
+
results: Array<
|
|
577
|
+
Error |
|
|
578
|
+
Object |
|
|
579
|
+
THydratedDocumentType
|
|
580
|
+
>
|
|
581
|
+
}
|
|
582
|
+
}>;
|
|
583
|
+
insertMany(
|
|
584
|
+
docs: Array<TRawDocType>,
|
|
585
|
+
options: InsertManyOptions & { lean: true, rawResult: true; }
|
|
586
|
+
): Promise<mongodb.InsertManyResult<Require_id<TRawDocType>>>;
|
|
587
|
+
insertMany<DocContents = TRawDocType>(
|
|
588
|
+
doc: DocContents | TRawDocType,
|
|
589
|
+
options: InsertManyOptions & { ordered: false; rawResult: true; }
|
|
590
|
+
): Promise<mongodb.InsertManyResult<Require_id<DocContents>> & {
|
|
591
|
+
mongoose: {
|
|
592
|
+
validationErrors: (CastError | Error.ValidatorError)[];
|
|
593
|
+
results: Array<
|
|
594
|
+
Error |
|
|
595
|
+
Object |
|
|
596
|
+
MergeType<THydratedDocumentType, DocContents>
|
|
597
|
+
>
|
|
598
|
+
}
|
|
599
|
+
}>;
|
|
600
|
+
insertMany(
|
|
601
|
+
docs: Array<TRawDocType>,
|
|
602
|
+
options: InsertManyOptions & { lean: true; }
|
|
603
|
+
): Promise<Array<Require_id<TRawDocType>>>;
|
|
604
|
+
insertMany(
|
|
605
|
+
docs: Array<TRawDocType>,
|
|
606
|
+
options: InsertManyOptions & { rawResult: true; }
|
|
607
|
+
): Promise<mongodb.InsertManyResult<Require_id<THydratedDocumentType>>>;
|
|
608
|
+
insertMany<DocContents = TRawDocType>(
|
|
609
|
+
docs: Array<DocContents | TRawDocType>,
|
|
610
|
+
options: InsertManyOptions & { lean: true; }
|
|
611
|
+
): Promise<Array<Require_id<DocContents>>>;
|
|
612
|
+
insertMany<DocContents = TRawDocType>(
|
|
613
|
+
docs: Array<DocContents | TRawDocType>,
|
|
614
|
+
options: InsertManyOptions & { rawResult: true; }
|
|
615
|
+
): Promise<mongodb.InsertManyResult<Require_id<DocContents>>>;
|
|
616
|
+
insertMany<DocContents = TRawDocType>(
|
|
617
|
+
doc: DocContents,
|
|
618
|
+
options: InsertManyOptions & { lean: true; }
|
|
619
|
+
): Promise<Array<Require_id<DocContents>>>;
|
|
620
|
+
insertMany<DocContents = TRawDocType>(
|
|
621
|
+
doc: DocContents,
|
|
622
|
+
options: InsertManyOptions & { rawResult: true; }
|
|
623
|
+
): Promise<mongodb.InsertManyResult<Require_id<DocContents>>>;
|
|
624
|
+
insertMany(
|
|
625
|
+
doc: Array<TRawDocType>,
|
|
626
|
+
options: InsertManyOptions
|
|
627
|
+
): Promise<Array<THydratedDocumentType>>;
|
|
628
|
+
insertMany<DocContents = TRawDocType>(
|
|
629
|
+
docs: Array<DocContents | TRawDocType>
|
|
630
|
+
): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
|
|
631
|
+
insertMany<DocContents = TRawDocType>(
|
|
632
|
+
doc: DocContents,
|
|
633
|
+
options: InsertManyOptions
|
|
634
|
+
): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
|
|
635
|
+
insertMany<DocContents = TRawDocType>(
|
|
636
|
+
docs: Array<DocContents | TRawDocType>,
|
|
637
|
+
options: InsertManyOptions
|
|
638
|
+
): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
|
|
639
|
+
insertMany<DocContents = TRawDocType>(
|
|
640
|
+
doc: DocContents
|
|
641
|
+
): Promise<
|
|
642
|
+
Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>
|
|
643
|
+
>;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Shortcut for saving one document to the database.
|
|
647
|
+
* `MyModel.insertOne(obj, options)` is almost equivalent to `new MyModel(obj).save(options)`.
|
|
648
|
+
* The difference is that `insertOne()` checks if `obj` is already a document, and checks for discriminators.
|
|
649
|
+
*/
|
|
650
|
+
insertOne(doc: Partial<ApplyBasicCreateCasting<TRawDocType>>, options?: SaveOptions): Promise<THydratedDocumentType>;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* List all [Atlas search indexes](https://www.mongodb.com/docs/atlas/atlas-search/create-index/) on this model's collection.
|
|
654
|
+
* This function only works when connected to MongoDB Atlas.
|
|
655
|
+
*/
|
|
656
|
+
listSearchIndexes(options?: mongodb.ListSearchIndexesOptions): Promise<Array<{ name: string }>>;
|
|
657
|
+
|
|
658
|
+
/** The name of the model */
|
|
659
|
+
modelName: string;
|
|
660
|
+
|
|
661
|
+
/** Populates document references. */
|
|
662
|
+
populate(
|
|
663
|
+
docs: Array<any>,
|
|
664
|
+
options: PopulateOptions | Array<PopulateOptions> | string
|
|
665
|
+
): Promise<Array<THydratedDocumentType>>;
|
|
666
|
+
populate(
|
|
667
|
+
doc: any, options: PopulateOptions | Array<PopulateOptions> | string
|
|
668
|
+
): Promise<THydratedDocumentType>;
|
|
669
|
+
populate<Paths>(
|
|
670
|
+
docs: Array<any>,
|
|
671
|
+
options: PopulateOptions | Array<PopulateOptions> | string
|
|
672
|
+
): Promise<Array<MergeType<THydratedDocumentType, Paths>>>;
|
|
673
|
+
populate<Paths>(
|
|
674
|
+
doc: any, options: PopulateOptions | Array<PopulateOptions> | string
|
|
675
|
+
): Promise<MergeType<THydratedDocumentType, Paths>>;
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Update an existing [Atlas search index](https://www.mongodb.com/docs/atlas/atlas-search/create-index/).
|
|
679
|
+
* This function only works when connected to MongoDB Atlas.
|
|
680
|
+
*/
|
|
681
|
+
updateSearchIndex(name: string, definition: AnyObject): Promise<void>;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Changes the Connection instance this model uses to make requests to MongoDB.
|
|
685
|
+
* This function is most useful for changing the Connection that a Model defined using `mongoose.model()` uses
|
|
686
|
+
* after initialization.
|
|
687
|
+
*/
|
|
688
|
+
useConnection(connection: Connection): this;
|
|
689
|
+
|
|
690
|
+
/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */
|
|
691
|
+
validate(): Promise<void>;
|
|
692
|
+
validate(obj: any): Promise<void>;
|
|
693
|
+
validate(obj: any, pathsOrOptions: PathsToValidate): Promise<void>;
|
|
694
|
+
validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise<void>;
|
|
695
|
+
|
|
696
|
+
/** Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/). */
|
|
697
|
+
watch<ResultType extends mongodb.Document = any, ChangeType extends mongodb.ChangeStreamDocument = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType, ChangeType>;
|
|
698
|
+
|
|
699
|
+
/** Adds a `$where` clause to this query */
|
|
700
|
+
$where(argument: string | Function): QueryWithHelpers<Array<THydratedDocumentType>, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find', TInstanceMethods & TVirtuals>;
|
|
701
|
+
|
|
702
|
+
/** Registered discriminators for this model. */
|
|
703
|
+
discriminators: { [name: string]: Model<any> } | undefined;
|
|
704
|
+
|
|
705
|
+
/** Translate any aliases fields/conditions so the final query or document object is pure */
|
|
706
|
+
translateAliases(raw: any): any;
|
|
707
|
+
|
|
708
|
+
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
709
|
+
distinct<DocKey extends string>(
|
|
710
|
+
field: DocKey,
|
|
711
|
+
filter?: QueryFilter<TRawDocType>,
|
|
712
|
+
options?: QueryOptions<TRawDocType>
|
|
713
|
+
): QueryWithHelpers<
|
|
714
|
+
Array<
|
|
715
|
+
DocKey extends keyof WithLevel1NestedPaths<TRawDocType>
|
|
716
|
+
? WithoutUndefined<Unpacked<WithLevel1NestedPaths<TRawDocType>[DocKey]>>
|
|
717
|
+
: unknown
|
|
718
|
+
>,
|
|
719
|
+
THydratedDocumentType,
|
|
720
|
+
TQueryHelpers,
|
|
721
|
+
TLeanResultType,
|
|
722
|
+
'distinct',
|
|
723
|
+
TInstanceMethods & TVirtuals
|
|
724
|
+
>;
|
|
725
|
+
distinct<DocKey extends string>(
|
|
726
|
+
field: DocKey,
|
|
727
|
+
filter?: Query<any, any>,
|
|
728
|
+
options?: QueryOptions<TRawDocType>
|
|
729
|
+
): QueryWithHelpers<
|
|
730
|
+
Array<
|
|
731
|
+
DocKey extends keyof WithLevel1NestedPaths<TRawDocType>
|
|
732
|
+
? WithoutUndefined<Unpacked<WithLevel1NestedPaths<TRawDocType>[DocKey]>>
|
|
733
|
+
: unknown
|
|
734
|
+
>,
|
|
735
|
+
THydratedDocumentType,
|
|
736
|
+
TQueryHelpers,
|
|
737
|
+
TLeanResultType,
|
|
738
|
+
'distinct',
|
|
739
|
+
TInstanceMethods & TVirtuals
|
|
740
|
+
>;
|
|
741
|
+
|
|
742
|
+
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
743
|
+
estimatedDocumentCount(options?: QueryOptions<TRawDocType>): QueryWithHelpers<
|
|
744
|
+
number,
|
|
745
|
+
THydratedDocumentType,
|
|
746
|
+
TQueryHelpers,
|
|
747
|
+
TLeanResultType,
|
|
748
|
+
'estimatedDocumentCount',
|
|
749
|
+
TInstanceMethods & TVirtuals
|
|
750
|
+
>;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Returns a document with its `_id` if at least one document exists in the database that matches
|
|
754
|
+
* the given `filter`, and `null` otherwise.
|
|
755
|
+
*/
|
|
756
|
+
exists(
|
|
757
|
+
filter: QueryFilter<TRawDocType>
|
|
758
|
+
): QueryWithHelpers<
|
|
759
|
+
{ _id: InferId<TRawDocType> } | null,
|
|
760
|
+
THydratedDocumentType,
|
|
761
|
+
TQueryHelpers,
|
|
762
|
+
TLeanResultType,
|
|
763
|
+
'findOne',
|
|
764
|
+
TInstanceMethods & TVirtuals
|
|
765
|
+
>;
|
|
766
|
+
exists(
|
|
767
|
+
filter: Query<any, any>
|
|
768
|
+
): QueryWithHelpers<
|
|
769
|
+
{ _id: InferId<TRawDocType> } | null,
|
|
770
|
+
THydratedDocumentType,
|
|
771
|
+
TQueryHelpers,
|
|
772
|
+
TLeanResultType,
|
|
773
|
+
'findOne',
|
|
774
|
+
TInstanceMethods & TVirtuals
|
|
775
|
+
>;
|
|
776
|
+
|
|
777
|
+
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
778
|
+
find<ResultDoc = THydratedDocumentType>(
|
|
779
|
+
filter: QueryFilter<TRawDocType>,
|
|
780
|
+
projection: ProjectionType<TRawDocType> | null | undefined,
|
|
781
|
+
options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
|
|
782
|
+
): QueryWithHelpers<
|
|
783
|
+
GetLeanResultType<TRawDocType, TRawDocType[], 'find'>,
|
|
784
|
+
ResultDoc,
|
|
785
|
+
TQueryHelpers,
|
|
786
|
+
TLeanResultType,
|
|
787
|
+
'find',
|
|
788
|
+
TInstanceMethods & TVirtuals
|
|
789
|
+
>;
|
|
790
|
+
find(
|
|
791
|
+
filter: Query<any, any>,
|
|
792
|
+
projection: ProjectionType<TRawDocType> | null | undefined,
|
|
793
|
+
options: QueryOptions<TRawDocType> & { lean: true } & mongodb.Abortable
|
|
794
|
+
): QueryWithHelpers<
|
|
795
|
+
GetLeanResultType<TRawDocType, TRawDocType[], 'find'>,
|
|
796
|
+
THydratedDocumentType,
|
|
797
|
+
TQueryHelpers,
|
|
798
|
+
TLeanResultType,
|
|
799
|
+
'find',
|
|
800
|
+
TInstanceMethods & TVirtuals
|
|
801
|
+
>;
|
|
802
|
+
find<ResultDoc = THydratedDocumentType>(
|
|
803
|
+
filter?: QueryFilter<TRawDocType>,
|
|
804
|
+
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
805
|
+
options?: QueryOptions<TRawDocType> & mongodb.Abortable
|
|
806
|
+
): QueryWithHelpers<
|
|
807
|
+
ResultDoc[],
|
|
808
|
+
ResultDoc,
|
|
809
|
+
TQueryHelpers,
|
|
810
|
+
TLeanResultType,
|
|
811
|
+
'find',
|
|
812
|
+
TInstanceMethods & TVirtuals
|
|
813
|
+
>;
|
|
814
|
+
find(
|
|
815
|
+
filter?: Query<any, any>,
|
|
816
|
+
projection?: ProjectionType<TRawDocType> | null | undefined,
|
|
817
|
+
options?: QueryOptions<TRawDocType> & mongodb.Abortable
|
|
818
|
+
): QueryWithHelpers<
|
|
819
|
+
THydratedDocumentType[],
|
|
820
|
+
THydratedDocumentType,
|
|
821
|
+
TQueryHelpers,
|
|
822
|
+
TLeanResultType,
|
|
823
|
+
'find',
|
|
824
|
+
TInstanceMethods & TVirtuals
|
|
825
|
+
>;
|
|
826
|
+
|
|
827
|
+
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
828
|
+
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
829
|
+
id: mongodb.ObjectId | any,
|
|
830
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
|
831
|
+
): QueryWithHelpers<
|
|
832
|
+
ModifyResult<TLeanResultType>,
|
|
833
|
+
ResultDoc,
|
|
834
|
+
TQueryHelpers,
|
|
835
|
+
TLeanResultType,
|
|
836
|
+
'findOneAndDelete',
|
|
837
|
+
TInstanceMethods & TVirtuals
|
|
838
|
+
>;
|
|
839
|
+
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
840
|
+
id: mongodb.ObjectId | any,
|
|
841
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
842
|
+
): QueryWithHelpers<
|
|
843
|
+
TLeanResultType | null,
|
|
844
|
+
ResultDoc,
|
|
845
|
+
TQueryHelpers,
|
|
846
|
+
TLeanResultType,
|
|
847
|
+
'findOneAndDelete',
|
|
848
|
+
TInstanceMethods & TVirtuals
|
|
849
|
+
>;
|
|
850
|
+
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
851
|
+
id: mongodb.ObjectId | any,
|
|
852
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
853
|
+
): QueryWithHelpers<
|
|
854
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<ResultDoc>,
|
|
855
|
+
ResultDoc,
|
|
856
|
+
TQueryHelpers,
|
|
857
|
+
TLeanResultType,
|
|
858
|
+
'findOneAndDelete',
|
|
859
|
+
TInstanceMethods & TVirtuals
|
|
860
|
+
>;
|
|
861
|
+
findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
|
862
|
+
id?: mongodb.ObjectId | any,
|
|
863
|
+
options?: QueryOptions<TRawDocType> | null
|
|
864
|
+
): QueryWithHelpers<
|
|
865
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
866
|
+
ResultDoc,
|
|
867
|
+
TQueryHelpers,
|
|
868
|
+
TLeanResultType,
|
|
869
|
+
'findOneAndDelete',
|
|
870
|
+
TInstanceMethods & TVirtuals
|
|
871
|
+
>;
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
875
|
+
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
876
|
+
filter: QueryFilter<TRawDocType>,
|
|
877
|
+
update: UpdateQuery<TRawDocType>,
|
|
878
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
|
879
|
+
): QueryWithHelpers<
|
|
880
|
+
ModifyResult<TRawDocType>,
|
|
881
|
+
ResultDoc,
|
|
882
|
+
TQueryHelpers,
|
|
883
|
+
TLeanResultType,
|
|
884
|
+
'findOneAndUpdate',
|
|
885
|
+
TInstanceMethods & TVirtuals
|
|
886
|
+
>;
|
|
887
|
+
findByIdAndUpdate(
|
|
888
|
+
filter: Query<any, any>,
|
|
889
|
+
update: UpdateQuery<TRawDocType>,
|
|
890
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
|
891
|
+
): QueryWithHelpers<
|
|
892
|
+
ModifyResult<TRawDocType>,
|
|
893
|
+
THydratedDocumentType,
|
|
894
|
+
TQueryHelpers,
|
|
895
|
+
TLeanResultType,
|
|
896
|
+
'findOneAndUpdate',
|
|
897
|
+
TInstanceMethods & TVirtuals
|
|
898
|
+
>;
|
|
899
|
+
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
900
|
+
id: mongodb.ObjectId | any,
|
|
901
|
+
update: UpdateQuery<TRawDocType>,
|
|
902
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
903
|
+
): QueryWithHelpers<
|
|
904
|
+
TLeanResultType | null,
|
|
905
|
+
ResultDoc,
|
|
906
|
+
TQueryHelpers,
|
|
907
|
+
TLeanResultType,
|
|
908
|
+
'findOneAndUpdate',
|
|
909
|
+
TInstanceMethods & TVirtuals
|
|
910
|
+
>;
|
|
911
|
+
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
912
|
+
id: mongodb.ObjectId | any,
|
|
913
|
+
update: UpdateQuery<TRawDocType>,
|
|
914
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
915
|
+
): QueryWithHelpers<
|
|
916
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<ResultDoc>,
|
|
917
|
+
ResultDoc,
|
|
918
|
+
TQueryHelpers,
|
|
919
|
+
TLeanResultType,
|
|
920
|
+
'findOneAndUpdate',
|
|
921
|
+
TInstanceMethods & TVirtuals
|
|
922
|
+
>;
|
|
923
|
+
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
924
|
+
id: mongodb.ObjectId | any,
|
|
925
|
+
update: UpdateQuery<TRawDocType>,
|
|
926
|
+
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
927
|
+
): QueryWithHelpers<
|
|
928
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType : ResultDoc,
|
|
929
|
+
ResultDoc,
|
|
930
|
+
TQueryHelpers,
|
|
931
|
+
TLeanResultType,
|
|
932
|
+
'findOneAndUpdate',
|
|
933
|
+
TInstanceMethods & TVirtuals
|
|
934
|
+
>;
|
|
935
|
+
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
936
|
+
id?: mongodb.ObjectId | any,
|
|
937
|
+
update?: UpdateQuery<TRawDocType>,
|
|
938
|
+
options?: QueryOptions<TRawDocType> | null
|
|
939
|
+
): QueryWithHelpers<
|
|
940
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
941
|
+
ResultDoc,
|
|
942
|
+
TQueryHelpers,
|
|
943
|
+
TLeanResultType,
|
|
944
|
+
'findOneAndUpdate',
|
|
945
|
+
TInstanceMethods & TVirtuals
|
|
946
|
+
>;
|
|
947
|
+
|
|
948
|
+
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
949
|
+
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
950
|
+
filter: QueryFilter<TRawDocType>,
|
|
951
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
952
|
+
): QueryWithHelpers<
|
|
953
|
+
TLeanResultType | null,
|
|
954
|
+
ResultDoc,
|
|
955
|
+
TQueryHelpers,
|
|
956
|
+
TLeanResultType,
|
|
957
|
+
'findOneAndDelete',
|
|
958
|
+
TInstanceMethods & TVirtuals
|
|
959
|
+
>;
|
|
960
|
+
findOneAndDelete(
|
|
961
|
+
filter: Query<any, any>,
|
|
962
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
963
|
+
): QueryWithHelpers<
|
|
964
|
+
TLeanResultType | null,
|
|
965
|
+
THydratedDocumentType,
|
|
966
|
+
TQueryHelpers,
|
|
967
|
+
TLeanResultType,
|
|
968
|
+
'findOneAndDelete',
|
|
969
|
+
TInstanceMethods & TVirtuals
|
|
970
|
+
>;
|
|
971
|
+
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
972
|
+
filter: QueryFilter<TRawDocType>,
|
|
973
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
974
|
+
): QueryWithHelpers<
|
|
975
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TRawDocType> : ModifyResult<ResultDoc>,
|
|
976
|
+
ResultDoc,
|
|
977
|
+
TQueryHelpers,
|
|
978
|
+
TLeanResultType,
|
|
979
|
+
'findOneAndDelete',
|
|
980
|
+
TInstanceMethods & TVirtuals
|
|
981
|
+
>;
|
|
982
|
+
findOneAndDelete(
|
|
983
|
+
filter: Query<any, any>,
|
|
984
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
985
|
+
): QueryWithHelpers<
|
|
986
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TRawDocType> : ModifyResult<THydratedDocumentType>,
|
|
987
|
+
THydratedDocumentType,
|
|
988
|
+
TQueryHelpers,
|
|
989
|
+
TLeanResultType,
|
|
990
|
+
'findOneAndDelete',
|
|
991
|
+
TInstanceMethods & TVirtuals
|
|
992
|
+
>;
|
|
993
|
+
findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
|
994
|
+
filter?: QueryFilter<TRawDocType> | null,
|
|
995
|
+
options?: QueryOptions<TRawDocType> | null
|
|
996
|
+
): QueryWithHelpers<
|
|
997
|
+
HasLeanOption<TSchema> extends true ? TRawDocType | null : ResultDoc | null,
|
|
998
|
+
ResultDoc,
|
|
999
|
+
TQueryHelpers,
|
|
1000
|
+
TLeanResultType,
|
|
1001
|
+
'findOneAndDelete',
|
|
1002
|
+
TInstanceMethods & TVirtuals
|
|
1003
|
+
>;
|
|
1004
|
+
findOneAndDelete(
|
|
1005
|
+
filter?: Query<any, any> | null,
|
|
1006
|
+
options?: QueryOptions<TRawDocType> | null
|
|
1007
|
+
): QueryWithHelpers<
|
|
1008
|
+
HasLeanOption<TSchema> extends true ? TRawDocType | null : THydratedDocumentType | null,
|
|
1009
|
+
THydratedDocumentType,
|
|
1010
|
+
TQueryHelpers,
|
|
1011
|
+
TLeanResultType,
|
|
1012
|
+
'findOneAndDelete',
|
|
1013
|
+
TInstanceMethods & TVirtuals
|
|
1014
|
+
>;
|
|
1015
|
+
|
|
1016
|
+
/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
|
|
1017
|
+
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
1018
|
+
filter: QueryFilter<TRawDocType>,
|
|
1019
|
+
replacement: TRawDocType | AnyObject,
|
|
1020
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
1021
|
+
): QueryWithHelpers<
|
|
1022
|
+
TLeanResultType | null,
|
|
1023
|
+
ResultDoc,
|
|
1024
|
+
TQueryHelpers,
|
|
1025
|
+
TLeanResultType,
|
|
1026
|
+
'findOneAndReplace',
|
|
1027
|
+
TInstanceMethods & TVirtuals
|
|
1028
|
+
>;
|
|
1029
|
+
findOneAndReplace(
|
|
1030
|
+
filter: Query<any, any>,
|
|
1031
|
+
replacement: TRawDocType | AnyObject,
|
|
1032
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
1033
|
+
): QueryWithHelpers<
|
|
1034
|
+
TLeanResultType | null,
|
|
1035
|
+
THydratedDocumentType,
|
|
1036
|
+
TQueryHelpers,
|
|
1037
|
+
TLeanResultType,
|
|
1038
|
+
'findOneAndReplace',
|
|
1039
|
+
TInstanceMethods & TVirtuals
|
|
1040
|
+
>;
|
|
1041
|
+
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
1042
|
+
filter: QueryFilter<TRawDocType>,
|
|
1043
|
+
replacement: TRawDocType | AnyObject,
|
|
1044
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
1045
|
+
): QueryWithHelpers<
|
|
1046
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<ResultDoc>,
|
|
1047
|
+
ResultDoc,
|
|
1048
|
+
TQueryHelpers,
|
|
1049
|
+
TLeanResultType,
|
|
1050
|
+
'findOneAndReplace',
|
|
1051
|
+
TInstanceMethods & TVirtuals
|
|
1052
|
+
>;
|
|
1053
|
+
findOneAndReplace(
|
|
1054
|
+
filter: Query<any, any>,
|
|
1055
|
+
replacement: TRawDocType | AnyObject,
|
|
1056
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
1057
|
+
): QueryWithHelpers<
|
|
1058
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<THydratedDocumentType>,
|
|
1059
|
+
THydratedDocumentType,
|
|
1060
|
+
TQueryHelpers,
|
|
1061
|
+
TLeanResultType,
|
|
1062
|
+
'findOneAndReplace',
|
|
1063
|
+
TInstanceMethods & TVirtuals
|
|
1064
|
+
>;
|
|
1065
|
+
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
1066
|
+
filter: QueryFilter<TRawDocType>,
|
|
1067
|
+
replacement: TRawDocType | AnyObject,
|
|
1068
|
+
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
1069
|
+
): QueryWithHelpers<
|
|
1070
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType : ResultDoc,
|
|
1071
|
+
ResultDoc,
|
|
1072
|
+
TQueryHelpers,
|
|
1073
|
+
TLeanResultType,
|
|
1074
|
+
'findOneAndReplace',
|
|
1075
|
+
TInstanceMethods & TVirtuals
|
|
1076
|
+
>;
|
|
1077
|
+
findOneAndReplace(
|
|
1078
|
+
filter: Query<any, any>,
|
|
1079
|
+
replacement: TRawDocType | AnyObject,
|
|
1080
|
+
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
1081
|
+
): QueryWithHelpers<
|
|
1082
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType : THydratedDocumentType,
|
|
1083
|
+
THydratedDocumentType,
|
|
1084
|
+
TQueryHelpers,
|
|
1085
|
+
TLeanResultType,
|
|
1086
|
+
'findOneAndReplace',
|
|
1087
|
+
TInstanceMethods & TVirtuals
|
|
1088
|
+
>;
|
|
1089
|
+
findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
|
1090
|
+
filter?: QueryFilter<TRawDocType>,
|
|
1091
|
+
replacement?: TRawDocType | AnyObject,
|
|
1092
|
+
options?: QueryOptions<TRawDocType> | null
|
|
1093
|
+
): QueryWithHelpers<
|
|
1094
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
1095
|
+
ResultDoc,
|
|
1096
|
+
TQueryHelpers,
|
|
1097
|
+
TLeanResultType,
|
|
1098
|
+
'findOneAndReplace',
|
|
1099
|
+
TInstanceMethods & TVirtuals
|
|
1100
|
+
>;
|
|
1101
|
+
findOneAndReplace(
|
|
1102
|
+
filter?: Query<any, any>,
|
|
1103
|
+
replacement?: TRawDocType | AnyObject,
|
|
1104
|
+
options?: QueryOptions<TRawDocType> | null
|
|
1105
|
+
): QueryWithHelpers<
|
|
1106
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : THydratedDocumentType | null,
|
|
1107
|
+
THydratedDocumentType,
|
|
1108
|
+
TQueryHelpers,
|
|
1109
|
+
TLeanResultType,
|
|
1110
|
+
'findOneAndReplace',
|
|
1111
|
+
TInstanceMethods & TVirtuals
|
|
1112
|
+
>;
|
|
1113
|
+
|
|
1114
|
+
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
1115
|
+
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
1116
|
+
filter: QueryFilter<TRawDocType>,
|
|
1117
|
+
update: UpdateQuery<TRawDocType>,
|
|
1118
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
|
1119
|
+
): QueryWithHelpers<
|
|
1120
|
+
ModifyResult<TRawDocType>,
|
|
1121
|
+
ResultDoc,
|
|
1122
|
+
TQueryHelpers,
|
|
1123
|
+
TLeanResultType,
|
|
1124
|
+
'findOneAndUpdate',
|
|
1125
|
+
TInstanceMethods & TVirtuals
|
|
1126
|
+
>;
|
|
1127
|
+
findOneAndUpdate(
|
|
1128
|
+
filter: Query<any, any>,
|
|
1129
|
+
update: UpdateQuery<TRawDocType>,
|
|
1130
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
|
1131
|
+
): QueryWithHelpers<
|
|
1132
|
+
ModifyResult<TRawDocType>,
|
|
1133
|
+
THydratedDocumentType,
|
|
1134
|
+
TQueryHelpers,
|
|
1135
|
+
TLeanResultType,
|
|
1136
|
+
'findOneAndUpdate',
|
|
1137
|
+
TInstanceMethods & TVirtuals
|
|
1138
|
+
>;
|
|
1139
|
+
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
1140
|
+
filter: QueryFilter<TRawDocType>,
|
|
1141
|
+
update: UpdateQuery<TRawDocType>,
|
|
1142
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
1143
|
+
): QueryWithHelpers<
|
|
1144
|
+
GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndUpdate'> | null,
|
|
1145
|
+
ResultDoc,
|
|
1146
|
+
TQueryHelpers,
|
|
1147
|
+
TLeanResultType,
|
|
1148
|
+
'findOneAndUpdate',
|
|
1149
|
+
TInstanceMethods & TVirtuals
|
|
1150
|
+
>;
|
|
1151
|
+
findOneAndUpdate(
|
|
1152
|
+
filter: Query<any, any>,
|
|
1153
|
+
update: UpdateQuery<TRawDocType>,
|
|
1154
|
+
options: QueryOptions<TRawDocType> & { lean: true }
|
|
1155
|
+
): QueryWithHelpers<
|
|
1156
|
+
GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndUpdate'> | null,
|
|
1157
|
+
THydratedDocumentType,
|
|
1158
|
+
TQueryHelpers,
|
|
1159
|
+
TLeanResultType,
|
|
1160
|
+
'findOneAndUpdate',
|
|
1161
|
+
TInstanceMethods & TVirtuals
|
|
1162
|
+
>;
|
|
1163
|
+
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
1164
|
+
filter: QueryFilter<TRawDocType>,
|
|
1165
|
+
update: UpdateQuery<TRawDocType>,
|
|
1166
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
1167
|
+
): QueryWithHelpers<
|
|
1168
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<ResultDoc>,
|
|
1169
|
+
ResultDoc,
|
|
1170
|
+
TQueryHelpers,
|
|
1171
|
+
TLeanResultType,
|
|
1172
|
+
'findOneAndUpdate',
|
|
1173
|
+
TInstanceMethods & TVirtuals
|
|
1174
|
+
>;
|
|
1175
|
+
findOneAndUpdate(
|
|
1176
|
+
filter: Query<any, any>,
|
|
1177
|
+
update: UpdateQuery<TRawDocType>,
|
|
1178
|
+
options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
|
1179
|
+
): QueryWithHelpers<
|
|
1180
|
+
HasLeanOption<TSchema> extends true ? ModifyResult<TLeanResultType> : ModifyResult<THydratedDocumentType>,
|
|
1181
|
+
THydratedDocumentType,
|
|
1182
|
+
TQueryHelpers,
|
|
1183
|
+
TLeanResultType,
|
|
1184
|
+
'findOneAndUpdate',
|
|
1185
|
+
TInstanceMethods & TVirtuals
|
|
1186
|
+
>;
|
|
1187
|
+
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
1188
|
+
filter: QueryFilter<TRawDocType>,
|
|
1189
|
+
update: UpdateQuery<TRawDocType>,
|
|
1190
|
+
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
1191
|
+
): QueryWithHelpers<
|
|
1192
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType : ResultDoc,
|
|
1193
|
+
ResultDoc,
|
|
1194
|
+
TQueryHelpers,
|
|
1195
|
+
TLeanResultType,
|
|
1196
|
+
'findOneAndUpdate',
|
|
1197
|
+
TInstanceMethods & TVirtuals
|
|
1198
|
+
>;
|
|
1199
|
+
findOneAndUpdate(
|
|
1200
|
+
filter: Query<any, any>,
|
|
1201
|
+
update: UpdateQuery<TRawDocType>,
|
|
1202
|
+
options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
|
1203
|
+
): QueryWithHelpers<
|
|
1204
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType : THydratedDocumentType,
|
|
1205
|
+
THydratedDocumentType,
|
|
1206
|
+
TQueryHelpers,
|
|
1207
|
+
TLeanResultType,
|
|
1208
|
+
'findOneAndUpdate',
|
|
1209
|
+
TInstanceMethods & TVirtuals
|
|
1210
|
+
>;
|
|
1211
|
+
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
1212
|
+
filter?: QueryFilter<TRawDocType>,
|
|
1213
|
+
update?: UpdateQuery<TRawDocType>,
|
|
1214
|
+
options?: QueryOptions<TRawDocType> | null
|
|
1215
|
+
): QueryWithHelpers<
|
|
1216
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
1217
|
+
ResultDoc,
|
|
1218
|
+
TQueryHelpers,
|
|
1219
|
+
TLeanResultType,
|
|
1220
|
+
'findOneAndUpdate',
|
|
1221
|
+
TInstanceMethods & TVirtuals
|
|
1222
|
+
>;
|
|
1223
|
+
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
|
1224
|
+
filter?: Query<any, any>,
|
|
1225
|
+
update?: UpdateQuery<TRawDocType>,
|
|
1226
|
+
options?: QueryOptions<TRawDocType> | null
|
|
1227
|
+
): QueryWithHelpers<
|
|
1228
|
+
HasLeanOption<TSchema> extends true ? TLeanResultType | null : ResultDoc | null,
|
|
1229
|
+
ResultDoc,
|
|
1230
|
+
TQueryHelpers,
|
|
1231
|
+
TLeanResultType,
|
|
1232
|
+
'findOneAndUpdate',
|
|
1233
|
+
TInstanceMethods & TVirtuals
|
|
1234
|
+
>;
|
|
1235
|
+
|
|
1236
|
+
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
1237
|
+
replaceOne<ResultDoc = THydratedDocumentType>(
|
|
1238
|
+
filter?: QueryFilter<TRawDocType>,
|
|
1239
|
+
replacement?: TRawDocType | AnyObject,
|
|
1240
|
+
options?: (mongodb.ReplaceOptions & QueryOptions<TRawDocType>) | null
|
|
1241
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TLeanResultType, 'replaceOne', TInstanceMethods & TVirtuals>;
|
|
1242
|
+
replaceOne<ResultDoc = THydratedDocumentType>(
|
|
1243
|
+
filter?: Query<any, any>,
|
|
1244
|
+
replacement?: TRawDocType | AnyObject,
|
|
1245
|
+
options?: (mongodb.ReplaceOptions & QueryOptions<TRawDocType>) | null
|
|
1246
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TLeanResultType, 'replaceOne', TInstanceMethods & TVirtuals>;
|
|
1247
|
+
|
|
1248
|
+
/** Apply changes made to this model's schema after this model was compiled. */
|
|
1249
|
+
recompileSchema(): void;
|
|
1250
|
+
|
|
1251
|
+
/** Schema the model uses. */
|
|
1252
|
+
schema: TSchema;
|
|
1253
|
+
|
|
1254
|
+
/** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */
|
|
1255
|
+
updateMany(
|
|
1256
|
+
filter: QueryFilter<TRawDocType>,
|
|
1257
|
+
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1258
|
+
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1259
|
+
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateMany', TInstanceMethods & TVirtuals>;
|
|
1260
|
+
updateMany(
|
|
1261
|
+
filter: Query<any, any>,
|
|
1262
|
+
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1263
|
+
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1264
|
+
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateMany', TInstanceMethods & TVirtuals>;
|
|
1265
|
+
|
|
1266
|
+
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
1267
|
+
updateOne(
|
|
1268
|
+
filter: QueryFilter<TRawDocType>,
|
|
1269
|
+
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1270
|
+
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1271
|
+
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateOne', TInstanceMethods & TVirtuals>;
|
|
1272
|
+
updateOne(
|
|
1273
|
+
filter: Query<any, any>,
|
|
1274
|
+
update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
|
1275
|
+
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
|
1276
|
+
): QueryWithHelpers<UpdateWriteOpResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'updateOne', TInstanceMethods & TVirtuals>;
|
|
1277
|
+
|
|
1278
|
+
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
1279
|
+
where<ResultDoc = THydratedDocumentType>(
|
|
1280
|
+
path: string,
|
|
1281
|
+
val?: any
|
|
1282
|
+
): QueryWithHelpers<HasLeanOption<TSchema> extends true ? TRawDocType[] : ResultDoc[], ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
|
1283
|
+
where<ResultDoc = THydratedDocumentType>(obj: object): QueryWithHelpers<
|
|
1284
|
+
HasLeanOption<TSchema> extends true ? TRawDocType[] : ResultDoc[],
|
|
1285
|
+
ResultDoc,
|
|
1286
|
+
TQueryHelpers,
|
|
1287
|
+
TLeanResultType,
|
|
1288
|
+
'find',
|
|
1289
|
+
TInstanceMethods & TVirtuals
|
|
1290
|
+
>;
|
|
1291
|
+
where<ResultDoc = THydratedDocumentType>(): QueryWithHelpers<
|
|
1292
|
+
HasLeanOption<TSchema> extends true ? TRawDocType[] : ResultDoc[],
|
|
1293
|
+
ResultDoc,
|
|
1294
|
+
TQueryHelpers,
|
|
1295
|
+
TLeanResultType,
|
|
1296
|
+
'find',
|
|
1297
|
+
TInstanceMethods & TVirtuals
|
|
1298
|
+
>;
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* If auto encryption is enabled, returns a ClientEncryption instance that is configured with the same settings that
|
|
1302
|
+
* Mongoose's underlying MongoClient is using. If the client has not yet been configured, returns null.
|
|
1303
|
+
*/
|
|
1304
|
+
clientEncryption(): mongodb.ClientEncryption | null;
|
|
1305
|
+
}
|
|
1306
|
+
}
|