@datanimbus/mongoose 6.13.10
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/.eslintrc.js +232 -0
- package/.mocharc.yml +4 -0
- package/LICENSE.md +22 -0
- package/README.md +387 -0
- package/SECURITY.md +1 -0
- package/browser.js +8 -0
- package/dist/browser.umd.js +2 -0
- package/index.js +63 -0
- package/lgtm.yml +12 -0
- package/lib/aggregate.js +1164 -0
- package/lib/browser.js +158 -0
- package/lib/browserDocument.js +101 -0
- package/lib/cast/boolean.js +32 -0
- package/lib/cast/date.js +41 -0
- package/lib/cast/decimal128.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.js +418 -0
- package/lib/collection.js +311 -0
- package/lib/connection.js +1574 -0
- package/lib/connectionstate.js +26 -0
- package/lib/cursor/AggregationCursor.js +380 -0
- package/lib/cursor/ChangeStream.js +154 -0
- package/lib/cursor/QueryCursor.js +538 -0
- package/lib/document.js +4771 -0
- package/lib/document_provider.js +30 -0
- package/lib/driver.js +15 -0
- package/lib/drivers/SPEC.md +4 -0
- package/lib/drivers/browser/ReadPreference.js +7 -0
- package/lib/drivers/browser/binary.js +14 -0
- package/lib/drivers/browser/decimal128.js +7 -0
- package/lib/drivers/browser/index.js +16 -0
- package/lib/drivers/browser/objectid.js +29 -0
- package/lib/drivers/node-mongodb-native/ReadPreference.js +47 -0
- package/lib/drivers/node-mongodb-native/binary.js +10 -0
- package/lib/drivers/node-mongodb-native/collection.js +460 -0
- package/lib/drivers/node-mongodb-native/connection.js +166 -0
- package/lib/drivers/node-mongodb-native/decimal128.js +7 -0
- package/lib/drivers/node-mongodb-native/index.js +12 -0
- package/lib/drivers/node-mongodb-native/objectid.js +16 -0
- package/lib/error/browserMissingSchema.js +28 -0
- package/lib/error/bulkWriteError.js +41 -0
- package/lib/error/cast.js +158 -0
- package/lib/error/disconnected.js +33 -0
- package/lib/error/divergentArray.js +38 -0
- package/lib/error/eachAsyncMultiError.js +41 -0
- package/lib/error/index.js +228 -0
- package/lib/error/messages.js +47 -0
- package/lib/error/missingSchema.js +31 -0
- package/lib/error/mongooseError.js +13 -0
- package/lib/error/notFound.js +45 -0
- package/lib/error/objectExpected.js +30 -0
- package/lib/error/objectParameter.js +30 -0
- package/lib/error/overwriteModel.js +30 -0
- package/lib/error/parallelSave.js +30 -0
- package/lib/error/parallelValidate.js +31 -0
- package/lib/error/serverSelection.js +61 -0
- package/lib/error/setOptionError.js +101 -0
- package/lib/error/strict.js +33 -0
- package/lib/error/strictPopulate.js +29 -0
- package/lib/error/syncIndexes.js +30 -0
- package/lib/error/validation.js +103 -0
- package/lib/error/validator.js +99 -0
- package/lib/error/version.js +36 -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 +177 -0
- package/lib/helpers/common.js +127 -0
- package/lib/helpers/cursor/eachAsync.js +222 -0
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
- package/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +12 -0
- package/lib/helpers/discriminator/getConstructor.js +26 -0
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +28 -0
- package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +27 -0
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +64 -0
- package/lib/helpers/document/applyDefaults.js +128 -0
- package/lib/helpers/document/cleanModifiedSubpaths.js +35 -0
- package/lib/helpers/document/compile.js +237 -0
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +50 -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 +27 -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 +59 -0
- package/lib/helpers/indexes/isDefaultIdIndex.js +18 -0
- package/lib/helpers/indexes/isIndexEqual.js +96 -0
- package/lib/helpers/indexes/isTextIndex.js +16 -0
- package/lib/helpers/isAsyncFunction.js +9 -0
- package/lib/helpers/isBsonType.js +16 -0
- package/lib/helpers/isMongooseObject.js +22 -0
- package/lib/helpers/isObject.js +16 -0
- package/lib/helpers/isPromise.js +6 -0
- package/lib/helpers/isSimpleValidator.js +22 -0
- package/lib/helpers/model/applyDefaultsToPOJO.js +52 -0
- package/lib/helpers/model/applyHooks.js +149 -0
- package/lib/helpers/model/applyMethods.js +70 -0
- package/lib/helpers/model/applyStaticHooks.js +71 -0
- package/lib/helpers/model/applyStatics.js +13 -0
- package/lib/helpers/model/castBulkWrite.js +240 -0
- package/lib/helpers/model/discriminator.js +218 -0
- package/lib/helpers/model/pushNestedArrayPaths.js +15 -0
- package/lib/helpers/once.js +12 -0
- package/lib/helpers/parallelLimit.js +55 -0
- package/lib/helpers/path/parentPaths.js +18 -0
- package/lib/helpers/path/setDottedPath.js +33 -0
- package/lib/helpers/pluralize.js +94 -0
- package/lib/helpers/populate/SkipPopulateValue.js +10 -0
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +124 -0
- package/lib/helpers/populate/assignVals.js +337 -0
- package/lib/helpers/populate/createPopulateQueryFilter.js +97 -0
- package/lib/helpers/populate/getModelsMapForPopulate.js +756 -0
- package/lib/helpers/populate/getSchemaTypes.js +233 -0
- package/lib/helpers/populate/getVirtual.js +72 -0
- package/lib/helpers/populate/leanPopulateMap.js +7 -0
- package/lib/helpers/populate/lookupLocalFields.js +40 -0
- package/lib/helpers/populate/markArraySubdocsPopulated.js +47 -0
- package/lib/helpers/populate/modelNamesFromRefPath.js +68 -0
- package/lib/helpers/populate/removeDeselectedForeignField.js +31 -0
- package/lib/helpers/populate/validateRef.js +19 -0
- package/lib/helpers/printJestWarning.js +21 -0
- package/lib/helpers/printStrictQueryWarning.js +11 -0
- package/lib/helpers/processConnectionOptions.js +65 -0
- package/lib/helpers/projection/applyProjection.js +77 -0
- package/lib/helpers/projection/hasIncludedChildren.js +41 -0
- package/lib/helpers/projection/isDefiningProjection.js +18 -0
- package/lib/helpers/projection/isExclusive.js +35 -0
- package/lib/helpers/projection/isInclusive.js +38 -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/promiseOrCallback.js +55 -0
- package/lib/helpers/query/applyGlobalOption.js +29 -0
- package/lib/helpers/query/applyQueryMiddleware.js +79 -0
- package/lib/helpers/query/cast$expr.js +282 -0
- package/lib/helpers/query/castFilterPath.js +54 -0
- package/lib/helpers/query/castUpdate.js +560 -0
- package/lib/helpers/query/completeMany.js +52 -0
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +90 -0
- package/lib/helpers/query/handleImmutable.js +28 -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 +49 -0
- package/lib/helpers/query/trusted.js +13 -0
- package/lib/helpers/query/validOps.js +24 -0
- package/lib/helpers/query/wrapThunk.js +31 -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/applyWriteConcern.js +30 -0
- package/lib/helpers/schema/cleanPositionalOperators.js +12 -0
- package/lib/helpers/schema/getIndexes.js +164 -0
- package/lib/helpers/schema/getKeysInSchemaOrder.js +28 -0
- package/lib/helpers/schema/getPath.js +37 -0
- package/lib/helpers/schema/handleIdOption.js +20 -0
- package/lib/helpers/schema/handleTimestampOption.js +24 -0
- package/lib/helpers/schema/idGetter.js +32 -0
- package/lib/helpers/schema/merge.js +28 -0
- package/lib/helpers/schematype/handleImmutable.js +50 -0
- package/lib/helpers/setDefaultsOnInsert.js +132 -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 +101 -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 +117 -0
- package/lib/helpers/update/castArrayFilters.js +109 -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 +249 -0
- package/lib/index.js +1338 -0
- package/lib/internal.js +46 -0
- package/lib/model.js +5474 -0
- package/lib/options/PopulateOptions.js +36 -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 +42 -0
- package/lib/options/SchemaTypeOptions.js +244 -0
- package/lib/options/VirtualOptions.js +164 -0
- package/lib/options/propertyOptions.js +8 -0
- package/lib/options/removeOptions.js +14 -0
- package/lib/options/saveOptions.js +14 -0
- package/lib/options.js +15 -0
- package/lib/plugins/index.js +7 -0
- package/lib/plugins/removeSubdocs.js +31 -0
- package/lib/plugins/saveSubdocs.js +66 -0
- package/lib/plugins/sharding.js +83 -0
- package/lib/plugins/trackTransaction.js +92 -0
- package/lib/plugins/validateBeforeSave.js +45 -0
- package/lib/promise_provider.js +49 -0
- package/lib/query.js +5982 -0
- package/lib/queryhelpers.js +353 -0
- package/lib/schema/DocumentArrayElement.js +100 -0
- package/lib/schema/SubdocumentPath.js +369 -0
- package/lib/schema/array.js +663 -0
- package/lib/schema/boolean.js +267 -0
- package/lib/schema/buffer.js +269 -0
- package/lib/schema/date.js +404 -0
- package/lib/schema/decimal128.js +210 -0
- package/lib/schema/documentarray.js +598 -0
- package/lib/schema/index.js +39 -0
- package/lib/schema/map.js +84 -0
- package/lib/schema/mixed.js +132 -0
- package/lib/schema/number.js +438 -0
- package/lib/schema/objectid.js +295 -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 +694 -0
- package/lib/schema/symbols.js +5 -0
- package/lib/schema/uuid.js +334 -0
- package/lib/schema.js +2665 -0
- package/lib/schematype.js +1727 -0
- package/lib/statemachine.js +207 -0
- package/lib/types/ArraySubdocument.js +189 -0
- package/lib/types/DocumentArray/index.js +113 -0
- package/lib/types/DocumentArray/isMongooseDocumentArray.js +5 -0
- package/lib/types/DocumentArray/methods/index.js +383 -0
- package/lib/types/array/index.js +116 -0
- package/lib/types/array/isMongooseArray.js +5 -0
- package/lib/types/array/methods/index.js +1014 -0
- package/lib/types/buffer.js +277 -0
- package/lib/types/decimal128.js +13 -0
- package/lib/types/index.js +20 -0
- package/lib/types/map.js +354 -0
- package/lib/types/objectid.js +41 -0
- package/lib/types/subdocument.js +432 -0
- package/lib/utils.js +1011 -0
- package/lib/validoptions.js +36 -0
- package/lib/virtualtype.js +175 -0
- package/package.json +164 -0
- package/scripts/build-browser.js +18 -0
- package/scripts/create-tarball.js +7 -0
- package/scripts/generateSearch.js +154 -0
- package/scripts/tsc-diagnostics-check.js +15 -0
- package/tools/auth.js +31 -0
- package/tools/repl.js +35 -0
- package/tools/sharded.js +46 -0
- package/tsconfig.json +9 -0
- package/types/aggregate.d.ts +174 -0
- package/types/augmentations.d.ts +9 -0
- package/types/callback.d.ts +8 -0
- package/types/collection.d.ts +44 -0
- package/types/connection.d.ts +242 -0
- package/types/cursor.d.ts +62 -0
- package/types/document.d.ts +266 -0
- package/types/error.d.ts +138 -0
- package/types/expressions.d.ts +2936 -0
- package/types/helpers.d.ts +32 -0
- package/types/index.d.ts +627 -0
- package/types/indexes.d.ts +98 -0
- package/types/inferschematype.d.ts +228 -0
- package/types/middlewares.d.ts +32 -0
- package/types/models.d.ts +488 -0
- package/types/mongooseoptions.d.ts +206 -0
- package/types/pipelinestage.d.ts +297 -0
- package/types/populate.d.ts +45 -0
- package/types/query.d.ts +659 -0
- package/types/schemaoptions.d.ts +231 -0
- package/types/schematypes.d.ts +478 -0
- package/types/session.d.ts +36 -0
- package/types/types.d.ts +104 -0
- package/types/utility.d.ts +43 -0
- package/types/validation.d.ts +34 -0
- package/types/virtuals.d.ts +14 -0
|
@@ -0,0 +1,488 @@
|
|
|
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>(name: string | number, schema: Schema, value?: string | number | ObjectId | DiscriminatorOptions): Model<D>;
|
|
15
|
+
discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string | number | ObjectId | DiscriminatorOptions): U;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface MongooseBulkWriteOptions {
|
|
19
|
+
skipValidation?: boolean;
|
|
20
|
+
strict?: boolean;
|
|
21
|
+
timestamps?: boolean | 'throw';
|
|
22
|
+
throwOnValidationError?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface InsertManyOptions extends
|
|
26
|
+
PopulateOption,
|
|
27
|
+
SessionOption {
|
|
28
|
+
limit?: number;
|
|
29
|
+
rawResult?: boolean;
|
|
30
|
+
ordered?: boolean;
|
|
31
|
+
lean?: boolean;
|
|
32
|
+
throwOnValidationError?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type InsertManyResult<T> = mongodb.InsertManyResult<T> & {
|
|
36
|
+
insertedIds: {
|
|
37
|
+
[key: number]: InferId<T>;
|
|
38
|
+
};
|
|
39
|
+
mongoose?: { validationErrors?: Array<Error.CastError | Error.ValidatorError> };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type UpdateWriteOpResult = mongodb.UpdateResult;
|
|
43
|
+
|
|
44
|
+
interface MapReduceOptions<T, K, R> {
|
|
45
|
+
map: Function | string;
|
|
46
|
+
reduce: (key: K, vals: T[]) => R;
|
|
47
|
+
/** query filter object. */
|
|
48
|
+
query?: any;
|
|
49
|
+
/** sort input objects using this key */
|
|
50
|
+
sort?: any;
|
|
51
|
+
/** max number of documents */
|
|
52
|
+
limit?: number;
|
|
53
|
+
/** keep temporary data default: false */
|
|
54
|
+
keeptemp?: boolean;
|
|
55
|
+
/** finalize function */
|
|
56
|
+
finalize?: (key: K, val: R) => R;
|
|
57
|
+
/** scope variables exposed to map/reduce/finalize during execution */
|
|
58
|
+
scope?: any;
|
|
59
|
+
/** it is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X default: false */
|
|
60
|
+
jsMode?: boolean;
|
|
61
|
+
/** provide statistics on job execution time. default: false */
|
|
62
|
+
verbose?: boolean;
|
|
63
|
+
readPreference?: string;
|
|
64
|
+
/** sets the output target for the map reduce job. default: {inline: 1} */
|
|
65
|
+
out?: {
|
|
66
|
+
/** the results are returned in an array */
|
|
67
|
+
inline?: number;
|
|
68
|
+
/**
|
|
69
|
+
* {replace: 'collectionName'} add the results to collectionName: the
|
|
70
|
+
* results replace the collection
|
|
71
|
+
*/
|
|
72
|
+
replace?: string;
|
|
73
|
+
/**
|
|
74
|
+
* {reduce: 'collectionName'} add the results to collectionName: if
|
|
75
|
+
* dups are detected, uses the reducer / finalize functions
|
|
76
|
+
*/
|
|
77
|
+
reduce?: string;
|
|
78
|
+
/**
|
|
79
|
+
* {merge: 'collectionName'} add the results to collectionName: if
|
|
80
|
+
* dups exist the new docs overwrite the old
|
|
81
|
+
*/
|
|
82
|
+
merge?: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface GeoSearchOptions {
|
|
87
|
+
/** x,y point to search for */
|
|
88
|
+
near: number[];
|
|
89
|
+
/** the maximum distance from the point near that a result can be */
|
|
90
|
+
maxDistance: number;
|
|
91
|
+
/** The maximum number of results to return */
|
|
92
|
+
limit?: number;
|
|
93
|
+
/** return the raw object instead of the Mongoose Model */
|
|
94
|
+
lean?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface ModifyResult<T> {
|
|
98
|
+
value: Require_id<T> | null;
|
|
99
|
+
/** see https://www.mongodb.com/docs/manual/reference/command/findAndModify/#lasterrorobject */
|
|
100
|
+
lastErrorObject?: {
|
|
101
|
+
updatedExisting?: boolean;
|
|
102
|
+
upserted?: mongodb.ObjectId;
|
|
103
|
+
};
|
|
104
|
+
ok: 0 | 1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type WriteConcern = mongodb.WriteConcern;
|
|
108
|
+
|
|
109
|
+
/** A list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list. */
|
|
110
|
+
type PathsToValidate = string[] | string;
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated
|
|
113
|
+
*/
|
|
114
|
+
type pathsToValidate = PathsToValidate;
|
|
115
|
+
|
|
116
|
+
interface SaveOptions extends
|
|
117
|
+
SessionOption {
|
|
118
|
+
checkKeys?: boolean;
|
|
119
|
+
j?: boolean;
|
|
120
|
+
safe?: boolean | WriteConcern;
|
|
121
|
+
timestamps?: boolean | QueryTimestampsConfig;
|
|
122
|
+
validateBeforeSave?: boolean;
|
|
123
|
+
validateModifiedOnly?: boolean;
|
|
124
|
+
w?: number | string;
|
|
125
|
+
wtimeout?: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface RemoveOptions extends SessionOption, Omit<mongodb.DeleteOptions, 'session'> {}
|
|
129
|
+
|
|
130
|
+
const Model: Model<any>;
|
|
131
|
+
interface Model<T, TQueryHelpers = {}, TMethodsAndOverrides = {}, TVirtuals = {}, TSchema = any> extends
|
|
132
|
+
NodeJS.EventEmitter,
|
|
133
|
+
AcceptsDiscriminator,
|
|
134
|
+
IndexManager,
|
|
135
|
+
SessionStarter {
|
|
136
|
+
new <DocType = T>(doc?: DocType, fields?: any | null, options?: boolean | AnyObject): HydratedDocument<
|
|
137
|
+
T,
|
|
138
|
+
TMethodsAndOverrides,
|
|
139
|
+
IfEquals<
|
|
140
|
+
TVirtuals,
|
|
141
|
+
{},
|
|
142
|
+
ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
|
|
143
|
+
TVirtuals
|
|
144
|
+
>
|
|
145
|
+
> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;
|
|
146
|
+
|
|
147
|
+
aggregate<R = any>(pipeline?: PipelineStage[], options?: AggregateOptions, callback?: Callback<R[]>): Aggregate<Array<R>>;
|
|
148
|
+
aggregate<R = any>(pipeline: PipelineStage[], callback?: Callback<R[]>): Aggregate<Array<R>>;
|
|
149
|
+
|
|
150
|
+
/** Base Mongoose instance the model uses. */
|
|
151
|
+
base: Mongoose;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* If this is a discriminator model, `baseModelName` is the name of
|
|
155
|
+
* the base model.
|
|
156
|
+
*/
|
|
157
|
+
baseModelName: string | undefined;
|
|
158
|
+
|
|
159
|
+
/* Cast the given POJO to the model's schema */
|
|
160
|
+
castObject(obj: AnyObject, options?: { ignoreCastErrors?: boolean }): T;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Sends multiple `insertOne`, `updateOne`, `updateMany`, `replaceOne`,
|
|
164
|
+
* `deleteOne`, and/or `deleteMany` operations to the MongoDB server in one
|
|
165
|
+
* command. This is faster than sending multiple independent operations (e.g.
|
|
166
|
+
* if you use `create()`) because with `bulkWrite()` there is only one network
|
|
167
|
+
* round trip to the MongoDB server.
|
|
168
|
+
*/
|
|
169
|
+
bulkWrite<DocContents = T>(
|
|
170
|
+
writes: Array<mongodb.AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends {} ? DocContents : any)>>,
|
|
171
|
+
options: mongodb.BulkWriteOptions & MongooseBulkWriteOptions & { ordered: false }
|
|
172
|
+
): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[] } }>;
|
|
173
|
+
bulkWrite<DocContents = T>(
|
|
174
|
+
writes: Array<mongodb.AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends {} ? DocContents : any)>>,
|
|
175
|
+
options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions
|
|
176
|
+
): Promise<mongodb.BulkWriteResult>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Sends multiple `save()` calls in a single `bulkWrite()`. This is faster than
|
|
180
|
+
* sending multiple `save()` calls because with `bulkSave()` there is only one
|
|
181
|
+
* network round trip to the MongoDB server.
|
|
182
|
+
*/
|
|
183
|
+
bulkSave(documents: Array<Document>, options?: mongodb.BulkWriteOptions & { timestamps?: boolean }): Promise<mongodb.BulkWriteResult>;
|
|
184
|
+
|
|
185
|
+
/** Collection the model uses. */
|
|
186
|
+
collection: Collection;
|
|
187
|
+
|
|
188
|
+
/** Creates a `count` query: counts the number of documents that match `filter`. */
|
|
189
|
+
count(callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
190
|
+
count(filter: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
191
|
+
|
|
192
|
+
/** Creates a `countDocuments` query: counts the number of documents that match `filter`. */
|
|
193
|
+
countDocuments(filter: FilterQuery<T>, options?: QueryOptions<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
194
|
+
countDocuments(callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
195
|
+
|
|
196
|
+
/** Creates a new document or documents */
|
|
197
|
+
create<DocContents = AnyKeys<T>>(docs: Array<DocContents>, options?: SaveOptions): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
198
|
+
create<DocContents = AnyKeys<T>>(docs: Array<DocContents>, options?: SaveOptions, callback?: Callback<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>>): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
199
|
+
create<DocContents = AnyKeys<T>>(docs: Array<DocContents>, callback: Callback<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>>): void;
|
|
200
|
+
create<DocContents = AnyKeys<T>>(doc: DocContents): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>;
|
|
201
|
+
create<DocContents = AnyKeys<T>>(...docs: Array<DocContents>): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
202
|
+
create<DocContents = AnyKeys<T>>(doc: DocContents, callback: Callback<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>): void;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Create the collection for this model. By default, if no indexes are specified,
|
|
206
|
+
* mongoose will not create the collection for the model until any documents are
|
|
207
|
+
* created. Use this method to create the collection explicitly.
|
|
208
|
+
*/
|
|
209
|
+
createCollection<T extends mongodb.Document>(options: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'> | null, callback: Callback<mongodb.Collection<T>>): void;
|
|
210
|
+
createCollection<T extends mongodb.Document>(callback: Callback<mongodb.Collection<T>>): void;
|
|
211
|
+
createCollection<T extends mongodb.Document>(options?: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'>): Promise<mongodb.Collection<T>>;
|
|
212
|
+
|
|
213
|
+
/** Connection the model uses. */
|
|
214
|
+
db: Connection;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Deletes all of the documents that match `conditions` from the collection.
|
|
218
|
+
* Behaves like `remove()`, but deletes all documents that match `conditions`
|
|
219
|
+
* regardless of the `single` option.
|
|
220
|
+
*/
|
|
221
|
+
deleteMany(filter?: FilterQuery<T>, options?: QueryOptions<T>, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
222
|
+
deleteMany(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
223
|
+
deleteMany(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Deletes the first document that matches `conditions` from the collection.
|
|
227
|
+
* Behaves like `remove()`, but deletes at most one document regardless of the
|
|
228
|
+
* `single` option.
|
|
229
|
+
*/
|
|
230
|
+
deleteOne(filter?: FilterQuery<T>, options?: QueryOptions<T>, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
231
|
+
deleteOne(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
232
|
+
deleteOne(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Event emitter that reports any errors that occurred. Useful for global error
|
|
236
|
+
* handling.
|
|
237
|
+
*/
|
|
238
|
+
events: NodeJS.EventEmitter;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Finds a single document by its _id field. `findById(id)` is almost*
|
|
242
|
+
* equivalent to `findOne({ _id: id })`. If you want to query by a document's
|
|
243
|
+
* `_id`, use `findById()` instead of `findOne()`.
|
|
244
|
+
*/
|
|
245
|
+
findById<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
246
|
+
id: any,
|
|
247
|
+
projection?: ProjectionType<T> | null,
|
|
248
|
+
options?: QueryOptions<T> | null,
|
|
249
|
+
callback?: Callback<ResultDoc | null>
|
|
250
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
251
|
+
findById<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
252
|
+
id: any,
|
|
253
|
+
projection?: ProjectionType<T> | null,
|
|
254
|
+
callback?: Callback<ResultDoc | null>
|
|
255
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
256
|
+
|
|
257
|
+
/** Finds one document. */
|
|
258
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
259
|
+
filter?: FilterQuery<T>,
|
|
260
|
+
projection?: ProjectionType<T> | null,
|
|
261
|
+
options?: QueryOptions<T> | null,
|
|
262
|
+
callback?: Callback<ResultDoc | null>
|
|
263
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
264
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
265
|
+
filter?: FilterQuery<T>,
|
|
266
|
+
projection?: ProjectionType<T> | null,
|
|
267
|
+
callback?: Callback<ResultDoc | null>
|
|
268
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
269
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
270
|
+
filter?: FilterQuery<T>,
|
|
271
|
+
callback?: Callback<ResultDoc | null>
|
|
272
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
276
|
+
* The document returned has no paths marked as modified initially.
|
|
277
|
+
*/
|
|
278
|
+
hydrate(obj: any, projection?: AnyObject, options?: { setters?: boolean }): HydratedDocument<T, TMethodsAndOverrides, TVirtuals>;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* This function is responsible for building [indexes](https://www.mongodb.com/docs/manual/indexes/),
|
|
282
|
+
* unless [`autoIndex`](http://mongoosejs.com/docs/guide.html#autoIndex) is turned off.
|
|
283
|
+
* Mongoose calls this function automatically when a model is created using
|
|
284
|
+
* [`mongoose.model()`](/docs/api/mongoose.html#mongoose_Mongoose-model) or
|
|
285
|
+
* [`connection.model()`](/docs/api/connection.html#connection_Connection-model), so you
|
|
286
|
+
* don't need to call it.
|
|
287
|
+
*/
|
|
288
|
+
init(callback?: CallbackWithoutResult): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>;
|
|
289
|
+
|
|
290
|
+
/** Inserts one or more new documents as a single `insertMany` call to the MongoDB server. */
|
|
291
|
+
insertMany<DocContents = T>(docs: Array<DocContents | T>, options: InsertManyOptions & { lean: true; }, callback: Callback<Array<MergeType<MergeType<T, DocContents>, Require_id<T>>>>): void;
|
|
292
|
+
insertMany<DocContents = T>(docs: Array<DocContents | T>, options: InsertManyOptions & { rawResult: true; }, callback: Callback<mongodb.InsertManyResult<T>>): void;
|
|
293
|
+
insertMany<DocContents = T>(docs: Array<DocContents | T>, callback: Callback<Array<HydratedDocument<MergeType<MergeType<T, DocContents>, Require_id<T>>, TMethodsAndOverrides, TVirtuals>>>): void;
|
|
294
|
+
insertMany<DocContents = T>(doc: DocContents, options: InsertManyOptions & { lean: true; }, callback: Callback<Array<MergeType<MergeType<T, DocContents>, Require_id<T>>>>): void;
|
|
295
|
+
insertMany<DocContents = T>(doc: DocContents, options: InsertManyOptions & { rawResult: true; }, callback: Callback<mongodb.InsertManyResult<T>>): void;
|
|
296
|
+
insertMany<DocContents = T>(doc: DocContents, options: InsertManyOptions & { lean?: false | undefined }, callback: Callback<Array<HydratedDocument<MergeType<MergeType<T, DocContents>, Require_id<T>>, TMethodsAndOverrides, TVirtuals>>>): void;
|
|
297
|
+
insertMany<DocContents = T>(doc: DocContents, callback: Callback<Array<HydratedDocument<MergeType<MergeType<T, DocContents>, Require_id<T>>, TMethodsAndOverrides, TVirtuals>>>): void;
|
|
298
|
+
|
|
299
|
+
insertMany<DocContents = T>(docs: Array<DocContents | T>, options: InsertManyOptions & { lean: true; }): Promise<Array<MergeType<MergeType<T, DocContents>, Require_id<T>>>>;
|
|
300
|
+
insertMany<DocContents = T>(
|
|
301
|
+
doc: DocContents,
|
|
302
|
+
options: InsertManyOptions & { ordered: false; rawResult: true; }
|
|
303
|
+
): Promise<mongodb.InsertManyResult<T> & {
|
|
304
|
+
mongoose: {
|
|
305
|
+
validationErrors: Error[];
|
|
306
|
+
results: Array<Error | Object | HydratedDocument<MergeType<MergeType<T, DocContents>, Require_id<T>>, TMethodsAndOverrides, TVirtuals>>
|
|
307
|
+
}
|
|
308
|
+
}>;
|
|
309
|
+
insertMany<DocContents = T>(docs: Array<DocContents | T>, options: InsertManyOptions & { rawResult: true; }): Promise<mongodb.InsertManyResult<T>>;
|
|
310
|
+
insertMany<DocContents = T>(docs: Array<DocContents | T>): Promise<Array<HydratedDocument<MergeType<MergeType<T, DocContents>, Require_id<T>>, TMethodsAndOverrides, TVirtuals>>>;
|
|
311
|
+
insertMany<DocContents = T>(doc: DocContents, options: InsertManyOptions & { lean: true; }): Promise<Array<MergeType<MergeType<T, DocContents>, Require_id<T>>>>;
|
|
312
|
+
insertMany<DocContents = T>(doc: DocContents, options: InsertManyOptions & { rawResult: true; }): Promise<mongodb.InsertManyResult<T>>;
|
|
313
|
+
insertMany<DocContents = T>(doc: DocContents, options: InsertManyOptions): Promise<Array<HydratedDocument<MergeType<MergeType<T, DocContents>, Require_id<T>>, TMethodsAndOverrides, TVirtuals>>>;
|
|
314
|
+
insertMany<DocContents = T>(doc: DocContents): Promise<Array<HydratedDocument<MergeType<MergeType<T, DocContents>, Require_id<T>>, TMethodsAndOverrides, TVirtuals>>>;
|
|
315
|
+
|
|
316
|
+
/** The name of the model */
|
|
317
|
+
modelName: string;
|
|
318
|
+
|
|
319
|
+
/** Populates document references. */
|
|
320
|
+
populate(
|
|
321
|
+
docs: Array<any>,
|
|
322
|
+
options: PopulateOptions | Array<PopulateOptions> | string
|
|
323
|
+
): Promise<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>>;
|
|
324
|
+
populate(
|
|
325
|
+
doc: any,
|
|
326
|
+
options: PopulateOptions | Array<PopulateOptions> | string,
|
|
327
|
+
): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>;
|
|
328
|
+
populate<Paths>(
|
|
329
|
+
docs: Array<any>,
|
|
330
|
+
options: PopulateOptions | Array<PopulateOptions> | string
|
|
331
|
+
): Promise<MergeType<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, Paths>[]>;
|
|
332
|
+
populate<Paths>(
|
|
333
|
+
doc: AnyObject,
|
|
334
|
+
options: PopulateOptions | Array<PopulateOptions> | string
|
|
335
|
+
): Promise<MergeType<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, Paths>>;
|
|
336
|
+
|
|
337
|
+
/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */
|
|
338
|
+
validate(callback?: CallbackWithoutResult): Promise<void>;
|
|
339
|
+
validate(optional: any, callback?: CallbackWithoutResult): Promise<void>;
|
|
340
|
+
validate(optional: any, pathsToValidate: PathsToValidate, callback?: CallbackWithoutResult): Promise<void>;
|
|
341
|
+
|
|
342
|
+
/** Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/). */
|
|
343
|
+
watch<ResultType extends mongodb.Document = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType>;
|
|
344
|
+
|
|
345
|
+
/** Adds a `$where` clause to this query */
|
|
346
|
+
$where(argument: string | Function): QueryWithHelpers<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
347
|
+
|
|
348
|
+
/** Registered discriminators for this model. */
|
|
349
|
+
discriminators: { [name: string]: Model<any> } | undefined;
|
|
350
|
+
|
|
351
|
+
/** Translate any aliases fields/conditions so the final query or document object is pure */
|
|
352
|
+
translateAliases(raw: any): any;
|
|
353
|
+
|
|
354
|
+
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
355
|
+
distinct<ReturnType = any>(field: string, filter?: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<Array<ReturnType>, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
356
|
+
|
|
357
|
+
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
358
|
+
estimatedDocumentCount(options?: QueryOptions<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Returns a document with its `_id` if at least one document exists in the database that matches
|
|
362
|
+
* the given `filter`, and `null` otherwise.
|
|
363
|
+
*/
|
|
364
|
+
exists(filter: FilterQuery<T>, callback: Callback<{ _id: InferId<T> } | null>): QueryWithHelpers<Pick<Document<T>, '_id'> | null, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
365
|
+
exists(filter: FilterQuery<T>): QueryWithHelpers<{ _id: InferId<T> } | null, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
366
|
+
|
|
367
|
+
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
368
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
369
|
+
filter: FilterQuery<T>,
|
|
370
|
+
projection?: ProjectionType<T> | null | undefined,
|
|
371
|
+
options?: QueryOptions<T> | null | undefined,
|
|
372
|
+
callback?: Callback<ResultDoc[]> | undefined
|
|
373
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
374
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
375
|
+
filter: FilterQuery<T>,
|
|
376
|
+
projection?: ProjectionType<T> | null | undefined,
|
|
377
|
+
callback?: Callback<ResultDoc[]> | undefined
|
|
378
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
379
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
380
|
+
filter: FilterQuery<T>,
|
|
381
|
+
callback?: Callback<ResultDoc[]> | undefined
|
|
382
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
383
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
384
|
+
callback?: Callback<ResultDoc[]> | undefined
|
|
385
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
386
|
+
|
|
387
|
+
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
388
|
+
findByIdAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
389
|
+
|
|
390
|
+
/** Creates a `findByIdAndRemove` query, filtering by the given `_id`. */
|
|
391
|
+
findByIdAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
392
|
+
|
|
393
|
+
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
394
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions<T> & { rawResult: true }, callback?: (err: CallbackError, doc: any, res: any) => void): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
395
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
396
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, update?: UpdateQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
397
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, callback: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
398
|
+
|
|
399
|
+
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
400
|
+
findOneAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
401
|
+
|
|
402
|
+
/** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */
|
|
403
|
+
findOneAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
404
|
+
|
|
405
|
+
/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
|
|
406
|
+
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, replacement: T | AnyObject, options: QueryOptions<T> & { rawResult: true }, callback?: (err: CallbackError, doc: any, res: any) => void): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
407
|
+
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, replacement: T | AnyObject, options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
408
|
+
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, replacement?: T | AnyObject, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
409
|
+
|
|
410
|
+
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
411
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
412
|
+
filter: FilterQuery<T>,
|
|
413
|
+
update: UpdateQuery<T>,
|
|
414
|
+
options: QueryOptions<T> & { rawResult: true },
|
|
415
|
+
callback?: (err: CallbackError, doc: any, res: any) => void
|
|
416
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
417
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
418
|
+
filter: FilterQuery<T>,
|
|
419
|
+
update: UpdateQuery<T>,
|
|
420
|
+
options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc,
|
|
421
|
+
callback?: (err: CallbackError, doc: ResultDoc, res: any) => void
|
|
422
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
423
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
424
|
+
filter?: FilterQuery<T>,
|
|
425
|
+
update?: UpdateQuery<T>,
|
|
426
|
+
options?: QueryOptions<T> | null,
|
|
427
|
+
callback?: (err: CallbackError, doc: T | null, res: any) => void
|
|
428
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
429
|
+
|
|
430
|
+
geoSearch<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
431
|
+
filter?: FilterQuery<T>,
|
|
432
|
+
options?: GeoSearchOptions,
|
|
433
|
+
callback?: Callback<Array<ResultDoc>>
|
|
434
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
435
|
+
|
|
436
|
+
/** Executes a mapReduce command. */
|
|
437
|
+
mapReduce<Key, Value>(
|
|
438
|
+
o: MapReduceOptions<T, Key, Value>,
|
|
439
|
+
callback?: Callback
|
|
440
|
+
): Promise<any>;
|
|
441
|
+
|
|
442
|
+
remove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: any, callback?: CallbackWithoutResult): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
|
|
443
|
+
remove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: any, options?: RemoveOptions, callback?: CallbackWithoutResult): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
|
|
444
|
+
|
|
445
|
+
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
446
|
+
replaceOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
447
|
+
filter?: FilterQuery<T>,
|
|
448
|
+
replacement?: T | AnyObject,
|
|
449
|
+
options?: QueryOptions<T> | null,
|
|
450
|
+
callback?: Callback
|
|
451
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
452
|
+
|
|
453
|
+
/** Schema the model uses. */
|
|
454
|
+
schema: Schema<T>;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @deprecated use `updateOne` or `updateMany` instead.
|
|
458
|
+
* Creates a `update` query: updates one or many documents that match `filter` with `update`, based on the `multi` option.
|
|
459
|
+
*/
|
|
460
|
+
update<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
461
|
+
filter?: FilterQuery<T>,
|
|
462
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
463
|
+
options?: QueryOptions<T> | null,
|
|
464
|
+
callback?: Callback
|
|
465
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
466
|
+
|
|
467
|
+
/** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */
|
|
468
|
+
updateMany<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
469
|
+
filter?: FilterQuery<T>,
|
|
470
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
471
|
+
options?: QueryOptions<T> | null,
|
|
472
|
+
callback?: Callback
|
|
473
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
474
|
+
|
|
475
|
+
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
476
|
+
updateOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
477
|
+
filter?: FilterQuery<T>,
|
|
478
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
479
|
+
options?: QueryOptions<T> | null,
|
|
480
|
+
callback?: Callback
|
|
481
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
482
|
+
|
|
483
|
+
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
484
|
+
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(path: string, val?: any): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
485
|
+
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(obj: object): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
486
|
+
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
487
|
+
}
|
|
488
|
+
}
|