@datanimbus/mongoose 9.13.1 → 9.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -70
- package/eslint.config.mjs +202 -0
- package/index.js +2 -1
- package/lib/aggregate.js +276 -174
- package/lib/cast/bigint.js +46 -0
- package/lib/cast/boolean.js +3 -3
- package/lib/cast/decimal128.js +4 -1
- package/lib/cast/double.js +56 -0
- package/lib/cast/int32.js +42 -0
- package/lib/cast/number.js +6 -6
- package/lib/cast/objectid.js +3 -3
- package/lib/cast/string.js +3 -3
- package/lib/cast/uuid.js +35 -0
- package/lib/cast.js +100 -92
- package/lib/collection.js +31 -22
- package/lib/connection.js +792 -507
- package/lib/constants.js +73 -0
- package/lib/cursor/{AggregationCursor.js → aggregationCursor.js} +205 -52
- package/lib/cursor/changeStream.js +218 -0
- package/lib/cursor/queryCursor.js +676 -0
- package/lib/defaults/schemaDefaultsCache.js +62 -0
- package/lib/document.js +2419 -1306
- package/lib/drivers/node-mongodb-native/bulkWriteResult.js +5 -0
- package/lib/drivers/node-mongodb-native/collection.js +101 -135
- package/lib/drivers/node-mongodb-native/connection.js +386 -28
- package/lib/drivers/node-mongodb-native/index.js +3 -5
- package/lib/error/browserMissingSchema.js +5 -4
- package/lib/error/bulkSaveIncompleteError.js +44 -0
- package/lib/error/cast.js +30 -21
- package/lib/error/createCollectionsError.js +26 -0
- package/lib/error/divergentArray.js +11 -9
- package/lib/error/eachAsyncMultiError.js +2 -2
- package/lib/error/index.js +38 -29
- package/lib/error/invalidSchemaOption.js +32 -0
- package/lib/error/messages.js +4 -3
- package/lib/error/missingSchema.js +8 -6
- package/lib/error/notFound.js +7 -5
- package/lib/error/objectExpected.js +9 -8
- package/lib/error/objectParameter.js +12 -11
- package/lib/error/overwriteModel.js +7 -6
- package/lib/error/parallelSave.js +11 -8
- package/lib/error/parallelValidate.js +9 -7
- package/lib/error/serverSelection.js +1 -0
- package/lib/error/setOptionError.js +11 -9
- package/lib/error/strict.js +12 -10
- package/lib/error/strictPopulate.js +11 -9
- package/lib/error/syncIndexes.js +2 -2
- package/lib/error/validation.js +11 -17
- package/lib/error/validator.js +9 -8
- package/lib/error/version.js +12 -10
- package/lib/filters/operators.js +8 -0
- package/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
- package/lib/helpers/buildMiddlewareFilter.js +42 -0
- package/lib/helpers/clone.js +121 -35
- package/lib/helpers/common.js +7 -7
- package/lib/helpers/cursor/eachAsync.js +14 -11
- package/lib/helpers/cursor/waitForInitialization.js +17 -0
- package/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +36 -0
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +1 -1
- package/lib/helpers/discriminator/getConstructor.js +9 -6
- package/lib/helpers/discriminator/getDiscriminatorByKey.js +1 -1
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
- package/lib/helpers/discriminator/getDiscriminatorValueFromFilter.js +30 -0
- package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +41 -9
- package/lib/helpers/document/applyDefaults.js +82 -14
- package/lib/helpers/document/applyTimestamps.js +106 -0
- package/lib/helpers/document/applyVirtuals.js +147 -0
- package/lib/helpers/document/cleanModifiedSubpaths.js +14 -4
- package/lib/helpers/document/compile.js +20 -15
- package/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +6 -3
- package/lib/helpers/document/handleSpreadDoc.js +2 -1
- package/lib/helpers/document/isInPathsToSave.js +24 -0
- package/lib/helpers/document/toObjectRecursive.js +49 -0
- package/lib/helpers/get.js +1 -1
- package/lib/helpers/getDefaultBulkwriteResult.js +11 -20
- package/lib/helpers/getInheritedProperty.js +28 -0
- package/lib/helpers/getOwnProperty.js +19 -0
- package/lib/helpers/indexes/applySchemaCollation.js +1 -1
- package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
- package/lib/helpers/indexes/getRelatedIndexes.js +8 -4
- package/lib/helpers/indexes/isDefaultIdIndex.js +1 -1
- package/lib/helpers/indexes/isIndexEqual.js +13 -12
- package/lib/helpers/indexes/isIndexSpecEqual.js +32 -0
- package/lib/helpers/indexes/isTimeseriesIndex.js +16 -0
- package/lib/helpers/isBsonType.js +3 -6
- package/lib/helpers/isMongooseDocument.js +24 -0
- package/lib/helpers/isMongooseObject.js +6 -4
- package/lib/helpers/isObject.js +2 -2
- package/lib/helpers/isPOJO.js +12 -0
- package/lib/helpers/isSimpleValidator.js +2 -2
- package/lib/helpers/minimize.js +41 -0
- package/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
- package/lib/helpers/model/applyHooks.js +72 -54
- package/lib/helpers/model/applyMethods.js +3 -3
- package/lib/helpers/model/applyStaticHooks.js +20 -50
- package/lib/helpers/model/castBulkWrite.js +278 -172
- package/lib/helpers/model/decorateBulkWriteResult.js +8 -0
- package/lib/helpers/model/discriminator.js +77 -21
- package/lib/helpers/omitUndefined.js +20 -0
- package/lib/helpers/parallelLimit.js +61 -34
- package/lib/helpers/path/setDottedPath.js +1 -1
- package/lib/helpers/pathTrie.js +167 -0
- package/lib/helpers/pluralize.js +5 -4
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +12 -7
- package/lib/helpers/populate/assignVals.js +46 -21
- package/lib/helpers/populate/createPopulateQueryFilter.js +13 -5
- package/lib/helpers/populate/getModelsMapForPopulate.js +250 -108
- package/lib/helpers/populate/getSchemaTypes.js +27 -30
- package/lib/helpers/populate/getVirtual.js +31 -0
- package/lib/helpers/populate/markArraySubdocsPopulated.js +6 -4
- package/lib/helpers/populate/modelNamesFromRefPath.js +11 -5
- package/lib/helpers/populate/removeDeselectedForeignField.js +3 -2
- package/lib/helpers/populate/setInheritedReadOptions.js +21 -0
- package/lib/helpers/populate/setPopulatedVirtualValue.js +33 -0
- package/lib/helpers/populate/splitPopulateQuery.js +81 -0
- package/lib/helpers/printJestWarning.js +1 -1
- package/lib/helpers/processConnectionOptions.js +7 -2
- package/lib/helpers/projection/applyProjection.js +8 -2
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/helpers/projection/isExclusive.js +8 -6
- package/lib/helpers/projection/isInclusive.js +2 -1
- package/lib/helpers/projection/isPathExcluded.js +3 -3
- package/lib/helpers/projection/isPathSelectedInclusive.js +1 -11
- package/lib/helpers/projection/isSubpath.js +1 -1
- package/lib/helpers/projection/parseProjection.js +9 -4
- package/lib/helpers/query/applyGlobalOption.js +9 -9
- package/lib/helpers/query/cast$expr.js +52 -23
- package/lib/helpers/query/castFilterPath.js +22 -22
- package/lib/helpers/query/castUpdate.js +207 -79
- package/lib/helpers/query/cloneMongooseOptions.js +44 -0
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +27 -13
- package/lib/helpers/query/handleImmutable.js +18 -2
- package/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
- package/lib/helpers/query/sanitizeFilter.js +3 -2
- package/lib/helpers/query/selectPopulatedFields.js +13 -0
- package/lib/helpers/query/validOps.js +1 -22
- package/lib/helpers/schema/applyPlugins.js +2 -2
- package/lib/helpers/schema/applyReadConcern.js +20 -0
- package/lib/helpers/schema/applyWriteConcern.js +12 -3
- package/lib/helpers/schema/cleanPositionalOperators.js +5 -3
- package/lib/helpers/schema/getIndexes.js +20 -13
- package/lib/helpers/schema/getKeysInSchemaOrder.js +13 -16
- package/lib/helpers/schema/getPath.js +11 -3
- package/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
- package/lib/helpers/schema/handleIdOption.js +1 -1
- package/lib/helpers/schema/idGetter.js +7 -2
- package/lib/helpers/schema/merge.js +9 -1
- package/lib/helpers/schematype/getConditionalHandler.js +23 -0
- package/lib/helpers/schematype/handleImmutable.js +1 -1
- package/lib/helpers/setDefaultsOnInsert.js +85 -43
- package/lib/helpers/symbols.js +4 -4
- package/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
- package/lib/helpers/timestamps/setupTimestamps.js +69 -37
- package/lib/helpers/update/applyTimestampsToChildren.js +1 -1
- package/lib/helpers/update/applyTimestampsToUpdate.js +53 -37
- package/lib/helpers/update/castArrayFilters.js +68 -29
- package/lib/helpers/update/decorateUpdateWithVersionKey.js +35 -0
- package/lib/helpers/update/modifiedPaths.js +2 -2
- package/lib/helpers/update/removeUnusedArrayFilters.js +11 -2
- package/lib/helpers/updateValidators.js +87 -128
- package/lib/index.js +6 -1320
- package/lib/internal.js +7 -1
- package/lib/model.js +2587 -2618
- package/lib/modifiedPathsSnapshot.js +9 -0
- package/lib/mongoose.js +1456 -0
- package/lib/options/saveOptions.js +2 -0
- package/lib/options/{SchemaArrayOptions.js → schemaArrayOptions.js} +16 -5
- package/lib/options/{SchemaBufferOptions.js → schemaBufferOptions.js} +2 -2
- package/lib/options/{SchemaDateOptions.js → schemaDateOptions.js} +1 -1
- package/lib/options/{SchemaDocumentArrayOptions.js → schemaDocumentArrayOptions.js} +24 -1
- package/lib/options/{SchemaMapOptions.js → schemaMapOptions.js} +1 -1
- package/lib/options/{SchemaNumberOptions.js → schemaNumberOptions.js} +5 -5
- package/lib/options/{SchemaObjectIdOptions.js → schemaObjectIdOptions.js} +4 -4
- package/lib/options/{SchemaStringOptions.js → schemaStringOptions.js} +10 -10
- package/lib/options/schemaSubdocumentOptions.js +89 -0
- package/lib/options/{SchemaTypeOptions.js → schemaTypeOptions.js} +28 -14
- package/lib/options/schemaUnionOptions.js +32 -0
- package/lib/options/{VirtualOptions.js → virtualOptions.js} +13 -13
- package/lib/options.js +4 -1
- package/lib/plugins/index.js +0 -2
- package/lib/plugins/saveSubdocs.js +85 -50
- package/lib/plugins/sharding.js +43 -15
- package/lib/plugins/trackTransaction.js +46 -34
- package/lib/query.js +1844 -1909
- package/lib/{queryhelpers.js → queryHelpers.js} +184 -81
- package/lib/schema/array.js +229 -169
- package/lib/schema/bigint.js +281 -0
- package/lib/schema/boolean.js +90 -26
- package/lib/schema/buffer.js +119 -50
- package/lib/schema/date.js +102 -38
- package/lib/schema/decimal128.js +88 -37
- package/lib/schema/{documentarray.js → documentArray.js} +259 -151
- package/lib/schema/documentArrayElement.js +180 -0
- package/lib/schema/double.js +244 -0
- package/lib/schema/index.js +12 -19
- package/lib/schema/int32.js +288 -0
- package/lib/schema/map.js +129 -20
- package/lib/schema/mixed.js +40 -26
- package/lib/schema/number.js +128 -51
- package/lib/schema/{objectid.js → objectId.js} +89 -47
- package/lib/schema/operators/exists.js +1 -1
- package/lib/schema/operators/geospatial.js +2 -2
- package/lib/schema/operators/text.js +4 -4
- package/lib/schema/string.js +125 -66
- package/lib/schema/subdocument.js +443 -0
- package/lib/schema/symbols.js +2 -0
- package/lib/schema/union.js +167 -0
- package/lib/schema/uuid.js +90 -120
- package/lib/schema.js +1267 -388
- package/lib/{schematype.js → schemaType.js} +481 -246
- package/lib/standardSchema/convertErrorToIssues.js +20 -0
- package/lib/{statemachine.js → stateMachine.js} +66 -17
- package/lib/tracing.js +38 -0
- package/lib/types/array/index.js +13 -10
- package/lib/types/array/methods/index.js +243 -63
- package/lib/types/{ArraySubdocument.js → arraySubdocument.js} +35 -14
- package/lib/types/buffer.js +31 -14
- package/lib/types/decimal128.js +1 -1
- package/lib/types/{DocumentArray → documentArray}/index.js +13 -13
- package/lib/types/{DocumentArray → documentArray}/methods/index.js +197 -31
- package/lib/types/double.js +13 -0
- package/lib/types/index.js +5 -2
- package/lib/types/map.js +62 -25
- package/lib/types/objectid.js +2 -2
- package/lib/types/subdocument.js +79 -58
- package/lib/types/uuid.js +13 -0
- package/lib/utils.js +201 -155
- package/lib/{validoptions.js → validOptions.js} +10 -2
- package/lib/{virtualtype.js → virtualType.js} +47 -18
- package/package.json +75 -92
- package/types/aggregate.d.ts +31 -7
- package/types/augmentations.d.ts +2 -2
- package/types/collection.d.ts +21 -16
- package/types/connection.d.ts +82 -27
- package/types/cursor.d.ts +15 -10
- package/types/document.d.ts +137 -56
- package/types/error.d.ts +11 -6
- package/types/expressions.d.ts +33 -2
- package/types/index.d.ts +805 -190
- package/types/indexes.d.ts +85 -13
- package/types/inferhydrateddoctype.d.ts +151 -0
- package/types/inferrawdoctype.d.ts +201 -0
- package/types/inferschematype.d.ts +287 -128
- package/types/middlewares.d.ts +50 -7
- package/types/models.d.ts +1555 -268
- package/types/mongooseoptions.d.ts +56 -7
- package/types/pipelinestage.d.ts +42 -3
- package/types/populate.d.ts +63 -1
- package/types/query.d.ts +592 -255
- package/types/schemaoptions.d.ts +78 -12
- package/types/schematypes.d.ts +254 -65
- package/types/session.d.ts +0 -4
- package/types/tracing.d.ts +10 -0
- package/types/types.d.ts +25 -8
- package/types/utility.d.ts +329 -30
- package/types/validation.d.ts +19 -14
- package/types/virtuals.d.ts +10 -10
- package/.eslintrc.js +0 -232
- package/.mocharc.yml +0 -4
- package/browser.js +0 -8
- package/lgtm.yml +0 -12
- package/lib/browser.js +0 -158
- package/lib/browserDocument.js +0 -101
- package/lib/cursor/ChangeStream.js +0 -154
- package/lib/cursor/QueryCursor.js +0 -545
- package/lib/document_provider.js +0 -30
- package/lib/drivers/browser/ReadPreference.js +0 -7
- package/lib/drivers/browser/binary.js +0 -14
- package/lib/drivers/browser/decimal128.js +0 -7
- package/lib/drivers/browser/index.js +0 -16
- package/lib/drivers/browser/objectid.js +0 -29
- package/lib/drivers/node-mongodb-native/ReadPreference.js +0 -47
- package/lib/drivers/node-mongodb-native/binary.js +0 -10
- package/lib/drivers/node-mongodb-native/decimal128.js +0 -7
- package/lib/drivers/node-mongodb-native/objectid.js +0 -16
- package/lib/error/disconnected.js +0 -33
- package/lib/helpers/printStrictQueryWarning.js +0 -11
- package/lib/helpers/promiseOrCallback.js +0 -55
- package/lib/helpers/query/applyQueryMiddleware.js +0 -79
- package/lib/helpers/query/completeMany.js +0 -52
- package/lib/helpers/query/wrapThunk.js +0 -36
- package/lib/options/SchemaSubdocumentOptions.js +0 -42
- package/lib/options/removeOptions.js +0 -14
- package/lib/plugins/removeSubdocs.js +0 -31
- package/lib/plugins/validateBeforeSave.js +0 -45
- package/lib/promise_provider.js +0 -49
- package/lib/schema/DocumentArrayElement.js +0 -100
- package/lib/schema/SubdocumentPath.js +0 -369
- package/scripts/build-browser.js +0 -18
- package/scripts/create-tarball.js +0 -7
- package/scripts/generateSearch.js +0 -154
- package/scripts/tsc-diagnostics-check.js +0 -15
- package/tools/auth.js +0 -31
- package/tools/repl.js +0 -35
- package/tools/sharded.js +0 -46
- package/tsconfig.json +0 -9
- /package/lib/{connectionstate.js → connectionState.js} +0 -0
- /package/lib/helpers/populate/{SkipPopulateValue.js → skipPopulateValue.js} +0 -0
- /package/lib/options/{PopulateOptions.js → populateOptions.js} +0 -0
- /package/lib/types/{DocumentArray → documentArray}/isMongooseDocumentArray.js +0 -0
|
@@ -11,15 +11,18 @@ const VALID_OPTIONS = Object.freeze([
|
|
|
11
11
|
'applyPluginsToDiscriminators',
|
|
12
12
|
'autoCreate',
|
|
13
13
|
'autoIndex',
|
|
14
|
+
'autoSearchIndex',
|
|
14
15
|
'bufferCommands',
|
|
15
16
|
'bufferTimeoutMS',
|
|
16
17
|
'cloneSchemas',
|
|
18
|
+
'createInitialConnection',
|
|
17
19
|
'debug',
|
|
20
|
+
'forceRepopulate',
|
|
18
21
|
'id',
|
|
19
|
-
'timestamps.createdAt.immutable',
|
|
20
22
|
'maxTimeMS',
|
|
21
23
|
'objectIdGetter',
|
|
22
24
|
'overwriteModels',
|
|
25
|
+
'returnDocument',
|
|
23
26
|
'returnOriginal',
|
|
24
27
|
'runValidators',
|
|
25
28
|
'sanitizeFilter',
|
|
@@ -29,8 +32,13 @@ const VALID_OPTIONS = Object.freeze([
|
|
|
29
32
|
'strict',
|
|
30
33
|
'strictPopulate',
|
|
31
34
|
'strictQuery',
|
|
35
|
+
'strictRead',
|
|
36
|
+
'timestamps.createdAt.immutable',
|
|
32
37
|
'toJSON',
|
|
33
|
-
'toObject'
|
|
38
|
+
'toObject',
|
|
39
|
+
'transactionAsyncLocalStorage',
|
|
40
|
+
'translateAliases',
|
|
41
|
+
'updatePipeline'
|
|
34
42
|
]);
|
|
35
43
|
|
|
36
44
|
module.exports = VALID_OPTIONS;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const modelNamesFromRefPath = require('./helpers/populate/modelNamesFromRefPath');
|
|
3
4
|
const utils = require('./utils');
|
|
4
5
|
|
|
6
|
+
const modelSymbol = require('./helpers/symbols').modelSymbol;
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* VirtualType constructor
|
|
7
10
|
*
|
|
@@ -12,19 +15,19 @@ const utils = require('./utils');
|
|
|
12
15
|
* const fullname = schema.virtual('fullname');
|
|
13
16
|
* fullname instanceof mongoose.VirtualType // true
|
|
14
17
|
*
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
18
|
+
* @param {object} options
|
|
19
|
+
* @param {string|Function} [options.ref] if `ref` is not nullish, this becomes a [populated virtual](https://mongoosejs.com/docs/populate.html#populate-virtuals)
|
|
20
|
+
* @param {string|Function} [options.localField] the local field to populate on if this is a populated virtual.
|
|
21
|
+
* @param {string|Function} [options.foreignField] the foreign field to populate on if this is a populated virtual.
|
|
22
|
+
* @param {boolean} [options.justOne=false] by default, a populated virtual is an array. If you set `justOne`, the populated virtual will be a single doc or `null`.
|
|
23
|
+
* @param {boolean} [options.getters=false] if you set this to `true`, Mongoose will call any custom getters you defined on this virtual
|
|
24
|
+
* @param {boolean} [options.count=false] if you set this to `true`, `populate()` will set this virtual to the number of populated documents, as opposed to the documents themselves, using [`Query#countDocuments()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.countDocuments())
|
|
25
|
+
* @param {object|Function} [options.match=null] add an extra match condition to `populate()`
|
|
26
|
+
* @param {number} [options.limit=null] add a default `limit` to the `populate()` query
|
|
27
|
+
* @param {number} [options.skip=null] add a default `skip` to the `populate()` query
|
|
28
|
+
* @param {number} [options.perDocumentLimit=null] For legacy reasons, `limit` with `populate()` may give incorrect results because it only executes a single query for every document being populated. If you set `perDocumentLimit`, Mongoose will ensure correct `limit` per document by executing a separate query for each document to `populate()`. For example, `.find().populate({ path: 'test', perDocumentLimit: 2 })` will execute 2 additional queries if `.find()` returns 2 documents.
|
|
29
|
+
* @param {object} [options.options=null] Additional options like `limit` and `lean`.
|
|
30
|
+
* @param {string} name
|
|
28
31
|
* @api public
|
|
29
32
|
*/
|
|
30
33
|
|
|
@@ -131,16 +134,16 @@ VirtualType.prototype.set = function(fn) {
|
|
|
131
134
|
/**
|
|
132
135
|
* Applies getters to `value`.
|
|
133
136
|
*
|
|
134
|
-
* @param {
|
|
137
|
+
* @param {any} value
|
|
135
138
|
* @param {Document} doc The document this virtual is attached to
|
|
136
|
-
* @return {
|
|
139
|
+
* @return {any} the value after applying all getters
|
|
137
140
|
* @api public
|
|
138
141
|
*/
|
|
139
142
|
|
|
140
143
|
VirtualType.prototype.applyGetters = function(value, doc) {
|
|
141
144
|
if (utils.hasUserDefinedProperty(this.options, ['ref', 'refPath']) &&
|
|
142
145
|
doc.$$populatedVirtuals &&
|
|
143
|
-
doc.$$populatedVirtuals
|
|
146
|
+
Object.hasOwn(doc.$$populatedVirtuals, this.path)) {
|
|
144
147
|
value = doc.$$populatedVirtuals[this.path];
|
|
145
148
|
}
|
|
146
149
|
|
|
@@ -154,9 +157,9 @@ VirtualType.prototype.applyGetters = function(value, doc) {
|
|
|
154
157
|
/**
|
|
155
158
|
* Applies setters to `value`.
|
|
156
159
|
*
|
|
157
|
-
* @param {
|
|
160
|
+
* @param {object} value
|
|
158
161
|
* @param {Document} doc
|
|
159
|
-
* @return {
|
|
162
|
+
* @return {any} the value after applying all setters
|
|
160
163
|
* @api public
|
|
161
164
|
*/
|
|
162
165
|
|
|
@@ -168,6 +171,32 @@ VirtualType.prototype.applySetters = function(value, doc) {
|
|
|
168
171
|
return v;
|
|
169
172
|
};
|
|
170
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Get the names of models used to populate this model given a doc
|
|
176
|
+
*
|
|
177
|
+
* @param {Document} doc
|
|
178
|
+
* @return {string[] | null}
|
|
179
|
+
* @api private
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
VirtualType.prototype._getModelNamesForPopulate = function _getModelNamesForPopulate(doc) {
|
|
183
|
+
if (this.options.refPath) {
|
|
184
|
+
return modelNamesFromRefPath(this.options.refPath, doc, this.path);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
let normalizedRef = null;
|
|
188
|
+
if (typeof this.options.ref === 'function' && !this.options.ref[modelSymbol]) {
|
|
189
|
+
normalizedRef = this.options.ref.call(doc, doc);
|
|
190
|
+
} else {
|
|
191
|
+
normalizedRef = this.options.ref;
|
|
192
|
+
}
|
|
193
|
+
if (normalizedRef != null && !Array.isArray(normalizedRef)) {
|
|
194
|
+
return [normalizedRef];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return normalizedRef;
|
|
198
|
+
};
|
|
199
|
+
|
|
171
200
|
/*!
|
|
172
201
|
* exports
|
|
173
202
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datanimbus/mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "9.13.
|
|
4
|
+
"version": "9.13.2",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -17,104 +17,109 @@
|
|
|
17
17
|
"orm",
|
|
18
18
|
"db"
|
|
19
19
|
],
|
|
20
|
+
"type": "commonjs",
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"
|
|
23
|
-
"kareem": "
|
|
24
|
-
"mongodb": "
|
|
23
|
+
"@standard-schema/spec": "^1.1.0",
|
|
24
|
+
"kareem": "3.4.1",
|
|
25
|
+
"mongodb": "~7.9",
|
|
25
26
|
"mpath": "0.9.0",
|
|
26
|
-
"mquery": "
|
|
27
|
+
"mquery": "6.0.1",
|
|
27
28
|
"ms": "2.1.3",
|
|
28
|
-
"sift": "
|
|
29
|
+
"sift": "17.1.4"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"acquit": "
|
|
37
|
-
"acquit-ignore": "0.2.1",
|
|
32
|
+
"@ark/attest": "0.58.0",
|
|
33
|
+
"@eslint/js": "^9.39.3",
|
|
34
|
+
"@mongodb-js/mongodb-downloader": "^3.0.5",
|
|
35
|
+
"@types/node": "^20.19.0",
|
|
36
|
+
"acquit": "1.4.0",
|
|
37
|
+
"acquit-ignore": "0.2.2",
|
|
38
38
|
"acquit-require": "0.1.1",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"benchmark": "2.1.4",
|
|
43
|
-
"bluebird": "3.7.2",
|
|
44
|
-
"broken-link-checker": "^0.7.8",
|
|
45
|
-
"buffer": "^5.6.0",
|
|
46
|
-
"cheerio": "1.0.0-rc.12",
|
|
47
|
-
"crypto-browserify": "3.12.0",
|
|
48
|
-
"dotenv": "16.0.3",
|
|
39
|
+
"ajv": "8.20.0",
|
|
40
|
+
"c8": "12.0.0",
|
|
41
|
+
"cheerio": "1.2.0",
|
|
49
42
|
"dox": "1.0.0",
|
|
50
|
-
"eslint": "
|
|
51
|
-
"eslint-plugin-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"highlight.js": "11.
|
|
43
|
+
"eslint": "10.13.0",
|
|
44
|
+
"eslint-plugin-mocha-no-only": "1.2.0",
|
|
45
|
+
"express": "5.3.0",
|
|
46
|
+
"fs-extra": "~11.4.0",
|
|
47
|
+
"globals": "^17.4.0",
|
|
48
|
+
"highlight.js": "11.12.0",
|
|
49
|
+
"linkinator": "8.x",
|
|
56
50
|
"lodash.isequal": "4.5.0",
|
|
57
51
|
"lodash.isequalwith": "4.4.0",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
52
|
+
"markdownlint-cli2": "0.24.1",
|
|
53
|
+
"marked": "18.1.2",
|
|
54
|
+
"mkdirp": "^3.0.1",
|
|
55
|
+
"mocha": "12.0.3",
|
|
56
|
+
"moment": "2.31.0",
|
|
57
|
+
"mongodb-client-encryption": "^7.2.0",
|
|
58
|
+
"mongodb-memory-server": "11.3.0",
|
|
59
|
+
"mongodb-runner": "^6.0.0",
|
|
63
60
|
"ncp": "^2.0.0",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"typescript": "4.9.5",
|
|
72
|
-
"uuid": "9.0.0",
|
|
73
|
-
"webpack": "5.75.0"
|
|
61
|
+
"pug": "3.0.4",
|
|
62
|
+
"sinon": "22.1.0",
|
|
63
|
+
"tstyche": "^7.0.0",
|
|
64
|
+
"typescript": "5.9.3",
|
|
65
|
+
"typescript-eslint": "^8.31.1",
|
|
66
|
+
"uuid": "14.0.3",
|
|
67
|
+
"xss": "1.0.17"
|
|
74
68
|
},
|
|
75
69
|
"directories": {
|
|
76
70
|
"lib": "./lib/mongoose"
|
|
77
71
|
},
|
|
78
72
|
"scripts": {
|
|
79
73
|
"docs:clean": "npm run docs:clean:stable",
|
|
80
|
-
"docs:clean:stable": "
|
|
81
|
-
"docs:clean:
|
|
82
|
-
"docs:
|
|
83
|
-
"docs:
|
|
84
|
-
"docs:copy:tmp:
|
|
85
|
-
"docs:
|
|
86
|
-
"docs:checkout:6x": "git checkout 6.x",
|
|
74
|
+
"docs:clean:stable": "rm -rf index.html && rm -rf ./docs/*.html && rm -rf ./docs/api && rm -rf ./docs/tutorials/*.html && rm -rf ./docs/typescript/*.html && rm -rf ./docs/production/*.html && rm -rf ./docs/*.html && rm -rf ./docs/source/_docs && rm -rf ./tmp",
|
|
75
|
+
"docs:clean:5x": "rm -rf index.html && rm -rf ./docs/5.x && rm -rf ./docs/source/_docs && rm -rf ./tmp",
|
|
76
|
+
"docs:clean:6x": "rm -rf index.html && rm -rf ./docs/6.x && rm -rf ./docs/source/_docs && rm -rf ./tmp",
|
|
77
|
+
"docs:copy:tmp": "mkdirp ./tmp/docs/css && mkdirp ./tmp/docs/js && mkdirp ./tmp/docs/images && mkdirp ./tmp/docs/tutorials && mkdirp ./tmp/docs/typescript && mkdirp ./tmp/docs/production && mkdirp ./tmp/docs/api && ncp ./docs/css ./tmp/docs/css --filter=.css$ && ncp ./docs/js ./tmp/docs/js --filter=.js$ && ncp ./docs/images ./tmp/docs/images && ncp ./docs/tutorials ./tmp/docs/tutorials && ncp ./docs/typescript ./tmp/docs/typescript && ncp ./docs/production ./tmp/docs/production && ncp ./docs/api ./tmp/docs/api && cp index.html ./tmp && cp docs/*.html ./tmp/docs/",
|
|
78
|
+
"docs:copy:tmp:5x": "rm -rf ./docs/5.x && ncp ./tmp ./docs/5.x",
|
|
79
|
+
"docs:copy:tmp:6x": "rm -rf ./docs/6.x && ncp ./tmp ./docs/6.x",
|
|
87
80
|
"docs:generate": "node ./scripts/website.js",
|
|
88
|
-
"docs:generate:search": "node ./scripts/generateSearch.js",
|
|
89
81
|
"docs:generate:sponsorData": "node ./scripts/loadSponsorData.js",
|
|
90
|
-
"docs:
|
|
91
|
-
"docs:merge:6x": "git merge 6.x",
|
|
92
|
-
"docs:test": "npm run docs:generate && npm run docs:generate:search",
|
|
82
|
+
"docs:test": "npm run docs:generate",
|
|
93
83
|
"docs:view": "node ./scripts/static.js",
|
|
94
|
-
"docs:prepare:publish:stable": "
|
|
95
|
-
"docs:prepare:publish:
|
|
96
|
-
"docs:
|
|
84
|
+
"docs:prepare:publish:stable": "git checkout gh-pages && git merge master && env GENERATE_SEARCH=true npm run docs:generate",
|
|
85
|
+
"docs:prepare:publish:5x": "git checkout 5.x && git merge 5.x && npm run docs:clean:stable && npm run docs:generate && npm run docs:copy:tmp && git checkout gh-pages && npm run docs:copy:tmp:5x",
|
|
86
|
+
"docs:prepare:publish:6x": "git checkout 6.x && git merge 6.x && npm run docs:clean:stable && env DOCS_DEPLOY=true npm run docs:generate && mv ./docs/6.x ./tmp && git checkout gh-pages && npm run docs:copy:tmp:6x",
|
|
87
|
+
"docs:prepare:publish:7x": "env DOCS_DEPLOY=true npm run docs:generate && git checkout gh-pages && rm -rf ./docs/7.x && mv ./tmp ./docs/7.x",
|
|
88
|
+
"docs:prepare:publish:8x": "env DOCS_DEPLOY=true npm run docs:generate && git checkout gh-pages && rm -rf ./docs/8.x && mv ./tmp ./docs/8.x",
|
|
89
|
+
"docs:check-links": "linkinator http://127.0.0.1:8089 --silent --recurse --skip cdn.carbonads.com --skip m.servedby-buysellads.com --skip \"127\\.0\\.0\\.1:8089/docs/\\d+.x\"",
|
|
90
|
+
"docs:update-mongodb-links": "node ./scripts/update-mongodb-links.js",
|
|
91
|
+
"checkLibCharset": "node ./scripts/checkLibCharset.js",
|
|
97
92
|
"lint": "eslint .",
|
|
98
|
-
"lint-js": "eslint . --ext .js",
|
|
93
|
+
"lint-js": "eslint . --ext .js --ext .cjs",
|
|
99
94
|
"lint-ts": "eslint . --ext .ts",
|
|
100
|
-
"lint-md": "
|
|
101
|
-
"build-browser": "(rm ./dist/* || true) && node ./scripts/build-browser.js",
|
|
102
|
-
"prepublishOnly": "npm run build-browser",
|
|
95
|
+
"lint-md": "markdownlint-cli2 \"docs/**/*.md\" \"docs/*.md\" \"*.md\"",
|
|
103
96
|
"release": "git pull && git push origin master --tags && npm publish",
|
|
97
|
+
"release-5x": "git pull origin 5.x && git push origin 5.x && git push origin 5.x --tags && npm publish --tag 5x",
|
|
104
98
|
"release-6x": "git pull origin 6.x && git push origin 6.x && git push origin 6.x --tags && npm publish --tag 6x",
|
|
105
99
|
"mongo": "node ./tools/repl.js",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"test
|
|
109
|
-
"test
|
|
110
|
-
"
|
|
111
|
-
"test-
|
|
112
|
-
"
|
|
100
|
+
"publish-7x": "npm publish --tag 7x",
|
|
101
|
+
"create-separate-require-instance": "rm -rf ./node_modules/mongoose-separate-require-instance && node ./scripts/create-tarball && tar -xzf mongoose.tgz -C ./node_modules && mv ./node_modules/package ./node_modules/mongoose-separate-require-instance",
|
|
102
|
+
"test": "mocha --exit --ignore \"test/encryption/**/*.test.js\" \"./test/**/*.test.js\"",
|
|
103
|
+
"test:ci": "npm run test -- --reporter min --timeout 10000",
|
|
104
|
+
"test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --allow-sys --allow-write ./test/deno.mjs",
|
|
105
|
+
"test-deno:ci": "npm run test-deno -- --reporter min",
|
|
106
|
+
"test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit --ignore \"test/encryption/**/*.test.js\" \"./test/**/*.test.js\"",
|
|
107
|
+
"test-rs:ci": "npm run test-rs -- --reporter min",
|
|
108
|
+
"test:types": "tstyche",
|
|
109
|
+
"setup-test-encryption": "node scripts/setup-encryption-tests.js",
|
|
110
|
+
"test-encryption": "mocha --exit ./test/encryption/*.test.js",
|
|
111
|
+
"test-encryption:ci": "npm run test-encryption -- --reporter min",
|
|
112
|
+
"tdd": "mocha --watch --inspect --ignore \"test/encryption/**/*.test.js\" \"./test/**/*.test.js\" --watch-files lib/**/*.js test/**/*.js",
|
|
113
|
+
"test-coverage": "c8 --reporter=html --reporter=text npm test",
|
|
114
|
+
"test-coverage:ci": "c8 --reporter=html --reporter=text npm run test:ci",
|
|
115
|
+
"ts-benchmark": "cd ./benchmarks/typescript/simple && npm install && npm run benchmark | node ../../../scripts/tsc-diagnostics-check",
|
|
116
|
+
"ts-benchmark:local": "node ./scripts/create-tarball && cd ./benchmarks/typescript/simple && rm -rf ./node_modules && npm install && npm run benchmark | node ../../../scripts/tsc-diagnostics-check",
|
|
117
|
+
"attest-benchmark": "node ./benchmarks/typescript/infer.bench.mts"
|
|
113
118
|
},
|
|
114
119
|
"main": "./index.js",
|
|
115
120
|
"types": "./types/index.d.ts",
|
|
116
121
|
"engines": {
|
|
117
|
-
"node": ">=
|
|
122
|
+
"node": ">=20.19.0"
|
|
118
123
|
},
|
|
119
124
|
"bugs": {
|
|
120
125
|
"url": "https://github.com/Automattic/mongoose/issues/new"
|
|
@@ -124,15 +129,6 @@
|
|
|
124
129
|
"url": "git://github.com/Automattic/mongoose.git"
|
|
125
130
|
},
|
|
126
131
|
"homepage": "https://mongoosejs.com",
|
|
127
|
-
"browser": "./dist/browser.umd.js",
|
|
128
|
-
"mocha": {
|
|
129
|
-
"extension": [
|
|
130
|
-
"test.js"
|
|
131
|
-
],
|
|
132
|
-
"watch-files": [
|
|
133
|
-
"test/**/*.js"
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
132
|
"config": {
|
|
137
133
|
"mongodbMemoryServer": {
|
|
138
134
|
"disablePostinstall": true
|
|
@@ -141,18 +137,5 @@
|
|
|
141
137
|
"funding": {
|
|
142
138
|
"type": "opencollective",
|
|
143
139
|
"url": "https://opencollective.com/mongoose"
|
|
144
|
-
},
|
|
145
|
-
"tsd": {
|
|
146
|
-
"directory": "test/types",
|
|
147
|
-
"compilerOptions": {
|
|
148
|
-
"esModuleInterop": false,
|
|
149
|
-
"strict": true,
|
|
150
|
-
"allowSyntheticDefaultImports": true,
|
|
151
|
-
"strictPropertyInitialization": false,
|
|
152
|
-
"noImplicitAny": false,
|
|
153
|
-
"strictNullChecks": true,
|
|
154
|
-
"module": "commonjs",
|
|
155
|
-
"target": "ES2017"
|
|
156
|
-
}
|
|
157
140
|
}
|
|
158
141
|
}
|
package/types/aggregate.d.ts
CHANGED
|
@@ -4,10 +4,25 @@ declare module 'mongoose' {
|
|
|
4
4
|
/** Extract generic type from Aggregate class */
|
|
5
5
|
type AggregateExtract<P> = P extends Aggregate<infer T> ? T : never;
|
|
6
6
|
|
|
7
|
-
interface AggregateOptions extends Omit<mongodb.AggregateOptions, 'session'>, SessionOption {
|
|
7
|
+
interface AggregateOptions extends Omit<mongodb.AggregateOptions & mongodb.Abortable, 'session'>, SessionOption {
|
|
8
|
+
/** set to `false` to skip all user-defined middleware, or `{ pre: false }` / `{ post: false }` to skip only pre or post hooks */
|
|
9
|
+
middleware?: boolean | SkipMiddlewareOptions;
|
|
8
10
|
[key: string]: any;
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
interface AggregateCursorMiddlewareOptions {
|
|
14
|
+
/** If `false`, skip pre aggregate middleware. Aggregate cursors do not run post aggregate middleware. */
|
|
15
|
+
pre?: boolean;
|
|
16
|
+
post?: never;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface AggregateCursorOptions extends Omit<mongodb.AggregationCursorOptions & mongodb.Abortable, 'session'>, SessionOption {
|
|
20
|
+
middleware?: boolean | AggregateCursorMiddlewareOptions;
|
|
21
|
+
transform?: (doc: any) => any;
|
|
22
|
+
useMongooseAggCursor?: boolean;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
11
26
|
class Aggregate<ResultType> implements SessionOperation {
|
|
12
27
|
/**
|
|
13
28
|
* Returns an asyncIterator for use with [`for/await/of` loops](https://thecodebarbarian.com/getting-started-with-async-iterators-in-node-js)
|
|
@@ -16,6 +31,9 @@ declare module 'mongoose' {
|
|
|
16
31
|
*/
|
|
17
32
|
[Symbol.asyncIterator](): AsyncIterableIterator<Unpacked<ResultType>>;
|
|
18
33
|
|
|
34
|
+
// Returns a string representation of this aggregation.
|
|
35
|
+
[Symbol.toStringTag]: string;
|
|
36
|
+
|
|
19
37
|
options: AggregateOptions;
|
|
20
38
|
|
|
21
39
|
/**
|
|
@@ -57,17 +75,14 @@ declare module 'mongoose' {
|
|
|
57
75
|
/**
|
|
58
76
|
* Sets the cursor option for the aggregation query
|
|
59
77
|
*/
|
|
60
|
-
cursor<DocType = any>(options?:
|
|
78
|
+
cursor<DocType = any>(options?: AggregateCursorOptions): Cursor<DocType>;
|
|
61
79
|
|
|
62
80
|
|
|
63
81
|
/** Executes the aggregate pipeline on the currently bound Model. */
|
|
64
|
-
exec(callback: Callback<ResultType>): void;
|
|
65
82
|
exec(): Promise<ResultType>;
|
|
66
83
|
|
|
67
84
|
/** Execute the aggregation with explain */
|
|
68
|
-
explain(verbosity: mongodb.ExplainVerbosityLike, callback: Callback<AnyObject>): void;
|
|
69
85
|
explain(verbosity: mongodb.ExplainVerbosityLike): Promise<AnyObject>;
|
|
70
|
-
explain(callback: Callback<AnyObject>): void;
|
|
71
86
|
explain(): Promise<AnyObject>;
|
|
72
87
|
|
|
73
88
|
/** Combines multiple aggregation pipelines. */
|
|
@@ -76,6 +91,12 @@ declare module 'mongoose' {
|
|
|
76
91
|
/** Appends a new $fill operator to this aggregate pipeline */
|
|
77
92
|
fill(arg: PipelineStage.Fill['$fill']): this;
|
|
78
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Executes the aggregation returning a `Promise` which will be
|
|
96
|
+
* resolved with `.finally()` chained.
|
|
97
|
+
*/
|
|
98
|
+
finally: Promise<ResultType>['finally'];
|
|
99
|
+
|
|
79
100
|
/** Appends new custom $graphLookup operator(s) to this aggregate pipeline, performing a recursive search on a collection. */
|
|
80
101
|
graphLookup(options: PipelineStage.GraphLookup['$graphLookup']): this;
|
|
81
102
|
|
|
@@ -104,7 +125,7 @@ declare module 'mongoose' {
|
|
|
104
125
|
* Binds this aggregate to a model.
|
|
105
126
|
* @param model the model to which the aggregate is to be bound
|
|
106
127
|
*/
|
|
107
|
-
model(model: Model<any>): this;
|
|
128
|
+
model(model: Model<any, any, any, any>): this;
|
|
108
129
|
|
|
109
130
|
/**
|
|
110
131
|
* Returns the current model bound to this aggregate object
|
|
@@ -117,8 +138,11 @@ declare module 'mongoose' {
|
|
|
117
138
|
/** Returns the current pipeline */
|
|
118
139
|
pipeline(): PipelineStage[];
|
|
119
140
|
|
|
141
|
+
/** Returns the current pipeline typed for use in `$unionWith` */
|
|
142
|
+
pipelineForUnionWith(): PipelineStage.UnionWithPipelineStage[];
|
|
143
|
+
|
|
120
144
|
/** Appends a new $project operator to this aggregate pipeline. */
|
|
121
|
-
project(arg: PipelineStage.Project['$project']): this;
|
|
145
|
+
project(arg: PipelineStage.Project['$project'] | string): this;
|
|
122
146
|
|
|
123
147
|
/** Sets the readPreference option for the aggregation query. */
|
|
124
148
|
read(pref: mongodb.ReadPreferenceLike): this;
|
package/types/augmentations.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// this import is required so that types get merged instead of completely overwritten
|
|
2
|
-
import '
|
|
2
|
+
import 'mongodb';
|
|
3
3
|
|
|
4
|
-
declare module '
|
|
4
|
+
declare module 'mongodb' {
|
|
5
5
|
interface ObjectId {
|
|
6
6
|
/** Mongoose automatically adds a conveniency "_id" getter on the base ObjectId class */
|
|
7
7
|
_id: this;
|
package/types/collection.d.ts
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
declare module 'mongoose' {
|
|
2
2
|
import mongodb = require('mongodb');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* mongodb.Collection interface so they've been commented out.
|
|
4
|
+
export class BaseCollection<T extends mongodb.Document> extends mongodb.Collection<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Collection constructor
|
|
7
|
+
* @param name name of the collection
|
|
8
|
+
* @param conn A MongooseConnection instance
|
|
9
|
+
* @param opts optional collection options
|
|
11
10
|
*/
|
|
11
|
+
constructor(name: string, conn: Connection, opts?: any);
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Abstract methods. Some of these are already defined on the
|
|
15
|
+
* mongodb.Collection interface so they've been commented out.
|
|
16
|
+
*/
|
|
12
17
|
ensureIndex(...args: any[]): any;
|
|
13
18
|
findAndModify(...args: any[]): any;
|
|
14
19
|
getIndexes(...args: any[]): any;
|
|
15
20
|
|
|
21
|
+
/** Formatter for debug print args */
|
|
22
|
+
$format(arg: any, color?: boolean, shell?: boolean): string;
|
|
23
|
+
/** Debug print helper */
|
|
24
|
+
$print(name: string, i: string | number, args: any[], color?: boolean, shell?: boolean): void;
|
|
25
|
+
|
|
16
26
|
/** The collection name */
|
|
17
|
-
collectionName: string;
|
|
27
|
+
get collectionName(): string;
|
|
18
28
|
/** The Connection instance */
|
|
19
29
|
conn: Connection;
|
|
20
30
|
/** The collection name */
|
|
@@ -24,21 +34,16 @@ declare module 'mongoose' {
|
|
|
24
34
|
/*
|
|
25
35
|
* section drivers/node-mongodb-native/collection.js
|
|
26
36
|
*/
|
|
27
|
-
|
|
37
|
+
class Collection<T extends mongodb.Document = mongodb.Document> extends BaseCollection<T> {
|
|
28
38
|
/**
|
|
29
39
|
* Collection constructor
|
|
30
40
|
* @param name name of the collection
|
|
31
41
|
* @param conn A MongooseConnection instance
|
|
32
42
|
* @param opts optional collection options
|
|
33
43
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** Formatter for debug print args */
|
|
37
|
-
$format(arg: any, color?: boolean, shell?: boolean): string;
|
|
38
|
-
/** Debug print helper */
|
|
39
|
-
$print(name: string, i: string | number, args: any[], color?: boolean, shell?: boolean): void;
|
|
44
|
+
constructor(name: string, conn: Connection, opts?: any);
|
|
45
|
+
|
|
40
46
|
/** Retrieves information about this collections indexes. */
|
|
41
47
|
getIndexes(): ReturnType<mongodb.Collection<T>['indexInformation']>;
|
|
42
48
|
}
|
|
43
|
-
let Collection: Collection;
|
|
44
49
|
}
|