@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.
Files changed (302) hide show
  1. package/README.md +80 -70
  2. package/eslint.config.mjs +202 -0
  3. package/index.js +2 -1
  4. package/lib/aggregate.js +276 -174
  5. package/lib/cast/bigint.js +46 -0
  6. package/lib/cast/boolean.js +3 -3
  7. package/lib/cast/decimal128.js +4 -1
  8. package/lib/cast/double.js +56 -0
  9. package/lib/cast/int32.js +42 -0
  10. package/lib/cast/number.js +6 -6
  11. package/lib/cast/objectid.js +3 -3
  12. package/lib/cast/string.js +3 -3
  13. package/lib/cast/uuid.js +35 -0
  14. package/lib/cast.js +100 -92
  15. package/lib/collection.js +31 -22
  16. package/lib/connection.js +792 -507
  17. package/lib/constants.js +73 -0
  18. package/lib/cursor/{AggregationCursor.js → aggregationCursor.js} +205 -52
  19. package/lib/cursor/changeStream.js +218 -0
  20. package/lib/cursor/queryCursor.js +676 -0
  21. package/lib/defaults/schemaDefaultsCache.js +62 -0
  22. package/lib/document.js +2419 -1306
  23. package/lib/drivers/node-mongodb-native/bulkWriteResult.js +5 -0
  24. package/lib/drivers/node-mongodb-native/collection.js +101 -135
  25. package/lib/drivers/node-mongodb-native/connection.js +386 -28
  26. package/lib/drivers/node-mongodb-native/index.js +3 -5
  27. package/lib/error/browserMissingSchema.js +5 -4
  28. package/lib/error/bulkSaveIncompleteError.js +44 -0
  29. package/lib/error/cast.js +30 -21
  30. package/lib/error/createCollectionsError.js +26 -0
  31. package/lib/error/divergentArray.js +11 -9
  32. package/lib/error/eachAsyncMultiError.js +2 -2
  33. package/lib/error/index.js +38 -29
  34. package/lib/error/invalidSchemaOption.js +32 -0
  35. package/lib/error/messages.js +4 -3
  36. package/lib/error/missingSchema.js +8 -6
  37. package/lib/error/notFound.js +7 -5
  38. package/lib/error/objectExpected.js +9 -8
  39. package/lib/error/objectParameter.js +12 -11
  40. package/lib/error/overwriteModel.js +7 -6
  41. package/lib/error/parallelSave.js +11 -8
  42. package/lib/error/parallelValidate.js +9 -7
  43. package/lib/error/serverSelection.js +1 -0
  44. package/lib/error/setOptionError.js +11 -9
  45. package/lib/error/strict.js +12 -10
  46. package/lib/error/strictPopulate.js +11 -9
  47. package/lib/error/syncIndexes.js +2 -2
  48. package/lib/error/validation.js +11 -17
  49. package/lib/error/validator.js +9 -8
  50. package/lib/error/version.js +12 -10
  51. package/lib/filters/operators.js +8 -0
  52. package/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
  53. package/lib/helpers/buildMiddlewareFilter.js +42 -0
  54. package/lib/helpers/clone.js +121 -35
  55. package/lib/helpers/common.js +7 -7
  56. package/lib/helpers/cursor/eachAsync.js +14 -11
  57. package/lib/helpers/cursor/waitForInitialization.js +17 -0
  58. package/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +36 -0
  59. package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +1 -1
  60. package/lib/helpers/discriminator/getConstructor.js +9 -6
  61. package/lib/helpers/discriminator/getDiscriminatorByKey.js +1 -1
  62. package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  63. package/lib/helpers/discriminator/getDiscriminatorValueFromFilter.js +30 -0
  64. package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
  65. package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +41 -9
  66. package/lib/helpers/document/applyDefaults.js +82 -14
  67. package/lib/helpers/document/applyTimestamps.js +106 -0
  68. package/lib/helpers/document/applyVirtuals.js +147 -0
  69. package/lib/helpers/document/cleanModifiedSubpaths.js +14 -4
  70. package/lib/helpers/document/compile.js +20 -15
  71. package/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
  72. package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +6 -3
  73. package/lib/helpers/document/handleSpreadDoc.js +2 -1
  74. package/lib/helpers/document/isInPathsToSave.js +24 -0
  75. package/lib/helpers/document/toObjectRecursive.js +49 -0
  76. package/lib/helpers/get.js +1 -1
  77. package/lib/helpers/getDefaultBulkwriteResult.js +11 -20
  78. package/lib/helpers/getInheritedProperty.js +28 -0
  79. package/lib/helpers/getOwnProperty.js +19 -0
  80. package/lib/helpers/indexes/applySchemaCollation.js +1 -1
  81. package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
  82. package/lib/helpers/indexes/getRelatedIndexes.js +8 -4
  83. package/lib/helpers/indexes/isDefaultIdIndex.js +1 -1
  84. package/lib/helpers/indexes/isIndexEqual.js +13 -12
  85. package/lib/helpers/indexes/isIndexSpecEqual.js +32 -0
  86. package/lib/helpers/indexes/isTimeseriesIndex.js +16 -0
  87. package/lib/helpers/isBsonType.js +3 -6
  88. package/lib/helpers/isMongooseDocument.js +24 -0
  89. package/lib/helpers/isMongooseObject.js +6 -4
  90. package/lib/helpers/isObject.js +2 -2
  91. package/lib/helpers/isPOJO.js +12 -0
  92. package/lib/helpers/isSimpleValidator.js +2 -2
  93. package/lib/helpers/minimize.js +41 -0
  94. package/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
  95. package/lib/helpers/model/applyHooks.js +72 -54
  96. package/lib/helpers/model/applyMethods.js +3 -3
  97. package/lib/helpers/model/applyStaticHooks.js +20 -50
  98. package/lib/helpers/model/castBulkWrite.js +278 -172
  99. package/lib/helpers/model/decorateBulkWriteResult.js +8 -0
  100. package/lib/helpers/model/discriminator.js +77 -21
  101. package/lib/helpers/omitUndefined.js +20 -0
  102. package/lib/helpers/parallelLimit.js +61 -34
  103. package/lib/helpers/path/setDottedPath.js +1 -1
  104. package/lib/helpers/pathTrie.js +167 -0
  105. package/lib/helpers/pluralize.js +5 -4
  106. package/lib/helpers/populate/assignRawDocsToIdStructure.js +12 -7
  107. package/lib/helpers/populate/assignVals.js +46 -21
  108. package/lib/helpers/populate/createPopulateQueryFilter.js +13 -5
  109. package/lib/helpers/populate/getModelsMapForPopulate.js +250 -108
  110. package/lib/helpers/populate/getSchemaTypes.js +27 -30
  111. package/lib/helpers/populate/getVirtual.js +31 -0
  112. package/lib/helpers/populate/markArraySubdocsPopulated.js +6 -4
  113. package/lib/helpers/populate/modelNamesFromRefPath.js +11 -5
  114. package/lib/helpers/populate/removeDeselectedForeignField.js +3 -2
  115. package/lib/helpers/populate/setInheritedReadOptions.js +21 -0
  116. package/lib/helpers/populate/setPopulatedVirtualValue.js +33 -0
  117. package/lib/helpers/populate/splitPopulateQuery.js +81 -0
  118. package/lib/helpers/printJestWarning.js +1 -1
  119. package/lib/helpers/processConnectionOptions.js +7 -2
  120. package/lib/helpers/projection/applyProjection.js +8 -2
  121. package/lib/helpers/projection/hasIncludedChildren.js +1 -1
  122. package/lib/helpers/projection/isExclusive.js +8 -6
  123. package/lib/helpers/projection/isInclusive.js +2 -1
  124. package/lib/helpers/projection/isPathExcluded.js +3 -3
  125. package/lib/helpers/projection/isPathSelectedInclusive.js +1 -11
  126. package/lib/helpers/projection/isSubpath.js +1 -1
  127. package/lib/helpers/projection/parseProjection.js +9 -4
  128. package/lib/helpers/query/applyGlobalOption.js +9 -9
  129. package/lib/helpers/query/cast$expr.js +52 -23
  130. package/lib/helpers/query/castFilterPath.js +22 -22
  131. package/lib/helpers/query/castUpdate.js +207 -79
  132. package/lib/helpers/query/cloneMongooseOptions.js +44 -0
  133. package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +27 -13
  134. package/lib/helpers/query/handleImmutable.js +18 -2
  135. package/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
  136. package/lib/helpers/query/sanitizeFilter.js +3 -2
  137. package/lib/helpers/query/selectPopulatedFields.js +13 -0
  138. package/lib/helpers/query/validOps.js +1 -22
  139. package/lib/helpers/schema/applyPlugins.js +2 -2
  140. package/lib/helpers/schema/applyReadConcern.js +20 -0
  141. package/lib/helpers/schema/applyWriteConcern.js +12 -3
  142. package/lib/helpers/schema/cleanPositionalOperators.js +5 -3
  143. package/lib/helpers/schema/getIndexes.js +20 -13
  144. package/lib/helpers/schema/getKeysInSchemaOrder.js +13 -16
  145. package/lib/helpers/schema/getPath.js +11 -3
  146. package/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
  147. package/lib/helpers/schema/handleIdOption.js +1 -1
  148. package/lib/helpers/schema/idGetter.js +7 -2
  149. package/lib/helpers/schema/merge.js +9 -1
  150. package/lib/helpers/schematype/getConditionalHandler.js +23 -0
  151. package/lib/helpers/schematype/handleImmutable.js +1 -1
  152. package/lib/helpers/setDefaultsOnInsert.js +85 -43
  153. package/lib/helpers/symbols.js +4 -4
  154. package/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
  155. package/lib/helpers/timestamps/setupTimestamps.js +69 -37
  156. package/lib/helpers/update/applyTimestampsToChildren.js +1 -1
  157. package/lib/helpers/update/applyTimestampsToUpdate.js +53 -37
  158. package/lib/helpers/update/castArrayFilters.js +68 -29
  159. package/lib/helpers/update/decorateUpdateWithVersionKey.js +35 -0
  160. package/lib/helpers/update/modifiedPaths.js +2 -2
  161. package/lib/helpers/update/removeUnusedArrayFilters.js +11 -2
  162. package/lib/helpers/updateValidators.js +87 -128
  163. package/lib/index.js +6 -1320
  164. package/lib/internal.js +7 -1
  165. package/lib/model.js +2587 -2618
  166. package/lib/modifiedPathsSnapshot.js +9 -0
  167. package/lib/mongoose.js +1456 -0
  168. package/lib/options/saveOptions.js +2 -0
  169. package/lib/options/{SchemaArrayOptions.js → schemaArrayOptions.js} +16 -5
  170. package/lib/options/{SchemaBufferOptions.js → schemaBufferOptions.js} +2 -2
  171. package/lib/options/{SchemaDateOptions.js → schemaDateOptions.js} +1 -1
  172. package/lib/options/{SchemaDocumentArrayOptions.js → schemaDocumentArrayOptions.js} +24 -1
  173. package/lib/options/{SchemaMapOptions.js → schemaMapOptions.js} +1 -1
  174. package/lib/options/{SchemaNumberOptions.js → schemaNumberOptions.js} +5 -5
  175. package/lib/options/{SchemaObjectIdOptions.js → schemaObjectIdOptions.js} +4 -4
  176. package/lib/options/{SchemaStringOptions.js → schemaStringOptions.js} +10 -10
  177. package/lib/options/schemaSubdocumentOptions.js +89 -0
  178. package/lib/options/{SchemaTypeOptions.js → schemaTypeOptions.js} +28 -14
  179. package/lib/options/schemaUnionOptions.js +32 -0
  180. package/lib/options/{VirtualOptions.js → virtualOptions.js} +13 -13
  181. package/lib/options.js +4 -1
  182. package/lib/plugins/index.js +0 -2
  183. package/lib/plugins/saveSubdocs.js +85 -50
  184. package/lib/plugins/sharding.js +43 -15
  185. package/lib/plugins/trackTransaction.js +46 -34
  186. package/lib/query.js +1844 -1909
  187. package/lib/{queryhelpers.js → queryHelpers.js} +184 -81
  188. package/lib/schema/array.js +229 -169
  189. package/lib/schema/bigint.js +281 -0
  190. package/lib/schema/boolean.js +90 -26
  191. package/lib/schema/buffer.js +119 -50
  192. package/lib/schema/date.js +102 -38
  193. package/lib/schema/decimal128.js +88 -37
  194. package/lib/schema/{documentarray.js → documentArray.js} +259 -151
  195. package/lib/schema/documentArrayElement.js +180 -0
  196. package/lib/schema/double.js +244 -0
  197. package/lib/schema/index.js +12 -19
  198. package/lib/schema/int32.js +288 -0
  199. package/lib/schema/map.js +129 -20
  200. package/lib/schema/mixed.js +40 -26
  201. package/lib/schema/number.js +128 -51
  202. package/lib/schema/{objectid.js → objectId.js} +89 -47
  203. package/lib/schema/operators/exists.js +1 -1
  204. package/lib/schema/operators/geospatial.js +2 -2
  205. package/lib/schema/operators/text.js +4 -4
  206. package/lib/schema/string.js +125 -66
  207. package/lib/schema/subdocument.js +443 -0
  208. package/lib/schema/symbols.js +2 -0
  209. package/lib/schema/union.js +167 -0
  210. package/lib/schema/uuid.js +90 -120
  211. package/lib/schema.js +1267 -388
  212. package/lib/{schematype.js → schemaType.js} +481 -246
  213. package/lib/standardSchema/convertErrorToIssues.js +20 -0
  214. package/lib/{statemachine.js → stateMachine.js} +66 -17
  215. package/lib/tracing.js +38 -0
  216. package/lib/types/array/index.js +13 -10
  217. package/lib/types/array/methods/index.js +243 -63
  218. package/lib/types/{ArraySubdocument.js → arraySubdocument.js} +35 -14
  219. package/lib/types/buffer.js +31 -14
  220. package/lib/types/decimal128.js +1 -1
  221. package/lib/types/{DocumentArray → documentArray}/index.js +13 -13
  222. package/lib/types/{DocumentArray → documentArray}/methods/index.js +197 -31
  223. package/lib/types/double.js +13 -0
  224. package/lib/types/index.js +5 -2
  225. package/lib/types/map.js +62 -25
  226. package/lib/types/objectid.js +2 -2
  227. package/lib/types/subdocument.js +79 -58
  228. package/lib/types/uuid.js +13 -0
  229. package/lib/utils.js +201 -155
  230. package/lib/{validoptions.js → validOptions.js} +10 -2
  231. package/lib/{virtualtype.js → virtualType.js} +47 -18
  232. package/package.json +75 -92
  233. package/types/aggregate.d.ts +31 -7
  234. package/types/augmentations.d.ts +2 -2
  235. package/types/collection.d.ts +21 -16
  236. package/types/connection.d.ts +82 -27
  237. package/types/cursor.d.ts +15 -10
  238. package/types/document.d.ts +137 -56
  239. package/types/error.d.ts +11 -6
  240. package/types/expressions.d.ts +33 -2
  241. package/types/index.d.ts +805 -190
  242. package/types/indexes.d.ts +85 -13
  243. package/types/inferhydrateddoctype.d.ts +151 -0
  244. package/types/inferrawdoctype.d.ts +201 -0
  245. package/types/inferschematype.d.ts +287 -128
  246. package/types/middlewares.d.ts +50 -7
  247. package/types/models.d.ts +1555 -268
  248. package/types/mongooseoptions.d.ts +56 -7
  249. package/types/pipelinestage.d.ts +42 -3
  250. package/types/populate.d.ts +63 -1
  251. package/types/query.d.ts +592 -255
  252. package/types/schemaoptions.d.ts +78 -12
  253. package/types/schematypes.d.ts +254 -65
  254. package/types/session.d.ts +0 -4
  255. package/types/tracing.d.ts +10 -0
  256. package/types/types.d.ts +25 -8
  257. package/types/utility.d.ts +329 -30
  258. package/types/validation.d.ts +19 -14
  259. package/types/virtuals.d.ts +10 -10
  260. package/.eslintrc.js +0 -232
  261. package/.mocharc.yml +0 -4
  262. package/browser.js +0 -8
  263. package/lgtm.yml +0 -12
  264. package/lib/browser.js +0 -158
  265. package/lib/browserDocument.js +0 -101
  266. package/lib/cursor/ChangeStream.js +0 -154
  267. package/lib/cursor/QueryCursor.js +0 -545
  268. package/lib/document_provider.js +0 -30
  269. package/lib/drivers/browser/ReadPreference.js +0 -7
  270. package/lib/drivers/browser/binary.js +0 -14
  271. package/lib/drivers/browser/decimal128.js +0 -7
  272. package/lib/drivers/browser/index.js +0 -16
  273. package/lib/drivers/browser/objectid.js +0 -29
  274. package/lib/drivers/node-mongodb-native/ReadPreference.js +0 -47
  275. package/lib/drivers/node-mongodb-native/binary.js +0 -10
  276. package/lib/drivers/node-mongodb-native/decimal128.js +0 -7
  277. package/lib/drivers/node-mongodb-native/objectid.js +0 -16
  278. package/lib/error/disconnected.js +0 -33
  279. package/lib/helpers/printStrictQueryWarning.js +0 -11
  280. package/lib/helpers/promiseOrCallback.js +0 -55
  281. package/lib/helpers/query/applyQueryMiddleware.js +0 -79
  282. package/lib/helpers/query/completeMany.js +0 -52
  283. package/lib/helpers/query/wrapThunk.js +0 -36
  284. package/lib/options/SchemaSubdocumentOptions.js +0 -42
  285. package/lib/options/removeOptions.js +0 -14
  286. package/lib/plugins/removeSubdocs.js +0 -31
  287. package/lib/plugins/validateBeforeSave.js +0 -45
  288. package/lib/promise_provider.js +0 -49
  289. package/lib/schema/DocumentArrayElement.js +0 -100
  290. package/lib/schema/SubdocumentPath.js +0 -369
  291. package/scripts/build-browser.js +0 -18
  292. package/scripts/create-tarball.js +0 -7
  293. package/scripts/generateSearch.js +0 -154
  294. package/scripts/tsc-diagnostics-check.js +0 -15
  295. package/tools/auth.js +0 -31
  296. package/tools/repl.js +0 -35
  297. package/tools/sharded.js +0 -46
  298. package/tsconfig.json +0 -9
  299. /package/lib/{connectionstate.js → connectionState.js} +0 -0
  300. /package/lib/helpers/populate/{SkipPopulateValue.js → skipPopulateValue.js} +0 -0
  301. /package/lib/options/{PopulateOptions.js → populateOptions.js} +0 -0
  302. /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 {Object} options
16
- * @param {String|Function} [options.ref] if `ref` is not nullish, this becomes a [populated virtual](/docs/populate.html#populate-virtuals)
17
- * @param {String|Function} [options.localField] the local field to populate on if this is a populated virtual.
18
- * @param {String|Function} [options.foreignField] the foreign field to populate on if this is a populated virtual.
19
- * @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`.
20
- * @param {Boolean} [options.getters=false] if you set this to `true`, Mongoose will call any custom getters you defined on this virtual
21
- * @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()`](/docs/api/query.html#query_Query-countDocuments)
22
- * @param {Object|Function} [options.match=null] add an extra match condition to `populate()`
23
- * @param {Number} [options.limit=null] add a default `limit` to the `populate()` query
24
- * @param {Number} [options.skip=null] add a default `skip` to the `populate()` query
25
- * @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.
26
- * @param {Object} [options.options=null] Additional options like `limit` and `lean`.
27
- * @param {String} name
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 {Object} value
137
+ * @param {any} value
135
138
  * @param {Document} doc The document this virtual is attached to
136
- * @return {Any} the value after applying all getters
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.hasOwnProperty(this.path)) {
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 {Object} value
160
+ * @param {object} value
158
161
  * @param {Document} doc
159
- * @return {Any} the value after applying all setters
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.1",
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
- "bson": "^4.7.2",
23
- "kareem": "2.5.1",
24
- "mongodb": "4.17.2",
23
+ "@standard-schema/spec": "^1.1.0",
24
+ "kareem": "3.4.1",
25
+ "mongodb": "~7.9",
25
26
  "mpath": "0.9.0",
26
- "mquery": "4.0.4",
27
+ "mquery": "6.0.1",
27
28
  "ms": "2.1.3",
28
- "sift": "16.0.1"
29
+ "sift": "17.1.4"
29
30
  },
30
31
  "devDependencies": {
31
- "@babel/core": "7.20.12",
32
- "@babel/preset-env": "7.20.2",
33
- "@sinonjs/fake-timers": "11.2.2",
34
- "@typescript-eslint/eslint-plugin": "5.50.0",
35
- "@typescript-eslint/parser": "5.50.0",
36
- "acquit": "1.3.0",
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
- "assert-browserify": "2.0.0",
40
- "axios": "1.1.3",
41
- "babel-loader": "8.2.5",
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": "8.33.0",
51
- "eslint-plugin-markdown": "^3.0.0",
52
- "eslint-plugin-mocha-no-only": "1.1.1",
53
- "express": "^4.18.1",
54
- "fs-extra": "~11.1.1",
55
- "highlight.js": "11.7.0",
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
- "marked": "4.2.12",
59
- "mkdirp": "^2.1.3",
60
- "mocha": "10.2.0",
61
- "moment": "2.x",
62
- "mongodb-memory-server": "8.11.4",
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
- "nyc": "15.1.0",
65
- "pug": "3.0.2",
66
- "q": "1.5.1",
67
- "sinon": "15.0.1",
68
- "stream-browserify": "3.0.0",
69
- "tmp": "0.2.1",
70
- "tsd": "0.25.0",
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": "rimraf index.html && rimraf -rf ./docs/*.html && rimraf -rf ./docs/api && rimraf -rf ./docs/tutorials/*.html && rimraf -rf ./docs/typescript/*.html && rimraf -rf ./docs/*.html && rimraf -rf ./docs/source/_docs && rimraf -rf ./tmp",
81
- "docs:clean:6x": "rimraf index.html && rimraf -rf ./docs/6.x && rimraf -rf ./docs/source/_docs && rimraf -rf ./tmp",
82
- "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/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/api ./tmp/docs/api && cp index.html ./tmp && cp docs/*.html ./tmp/docs/",
83
- "docs:move:6x:tmp": "mv ./docs/6.x ./tmp",
84
- "docs:copy:tmp:6x": "rimraf ./docs/6.x && ncp ./tmp ./docs/6.x",
85
- "docs:checkout:gh-pages": "git checkout gh-pages",
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:merge:stable": "git merge master",
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": "npm run docs:checkout:gh-pages && npm run docs:merge:stable && npm run docs:clean:stable && npm run docs:generate && npm run docs:generate:search",
95
- "docs:prepare:publish:6x": "npm run docs:checkout:6x && npm run docs:merge:6x && npm run docs:clean:stable && env DOCS_DEPLOY=true npm run docs:generate && npm run docs:move:6x:tmp && npm run docs:checkout:gh-pages && npm run docs:copy:tmp:6x",
96
- "docs:check-links": "blc http://127.0.0.1:8089 -ro",
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": "eslint . --ext .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
- "test": "mocha --exit ./test/*.test.js",
107
- "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --allow-sys --allow-write ./test/deno.js",
108
- "test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js",
109
- "test-tsd": "node ./test/types/check-types-filename && tsd",
110
- "tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}",
111
- "test-coverage": "nyc --reporter=html --reporter=text npm test",
112
- "ts-benchmark": "cd ./benchmarks/typescript/simple && npm install && npm run benchmark | node ../../../scripts/tsc-diagnostics-check"
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": ">=12.0.0"
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
  }
@@ -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?: Record<string, unknown>): Cursor<DocType>;
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;
@@ -1,7 +1,7 @@
1
1
  // this import is required so that types get merged instead of completely overwritten
2
- import 'bson';
2
+ import 'mongodb';
3
3
 
4
- declare module 'bson' {
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;
@@ -1,20 +1,30 @@
1
1
  declare module 'mongoose' {
2
2
  import mongodb = require('mongodb');
3
3
 
4
- /*
5
- * section collection.js
6
- */
7
- interface CollectionBase<T extends mongodb.Document> extends mongodb.Collection<T> {
8
- /*
9
- * Abstract methods. Some of these are already defined on the
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
- interface Collection<T extends mongodb.Document = mongodb.Document> extends CollectionBase<T> {
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
- // eslint-disable-next-line @typescript-eslint/no-misused-new
35
- new(name: string, conn: Connection, opts?: any): Collection<T>;
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
  }