mongoose 9.7.3 → 9.7.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "9.7.3",
4
+ "version": "9.7.4",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -29,7 +29,7 @@
29
29
  "sift": "17.1.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@ark/attest": "0.56.0",
32
+ "@ark/attest": "0.56.1",
33
33
  "@eslint/js": "^9.39.3",
34
34
  "@mongodb-js/mongodb-downloader": "^1.0.0",
35
35
  "@types/node": "^20.19.0",
@@ -40,7 +40,7 @@
40
40
  "c8": "11.0.0",
41
41
  "cheerio": "1.2.0",
42
42
  "dox": "1.0.0",
43
- "eslint": "10.4.1",
43
+ "eslint": "10.6.0",
44
44
  "eslint-plugin-mocha-no-only": "1.2.0",
45
45
  "express": "5.2.1",
46
46
  "fs-extra": "~11.3.0",
@@ -51,7 +51,7 @@
51
51
  "lodash.isequal": "4.5.0",
52
52
  "lodash.isequalwith": "4.4.0",
53
53
  "markdownlint-cli2": "0.22.1",
54
- "marked": "18.0.4",
54
+ "marked": "18.0.5",
55
55
  "mkdirp": "^3.0.1",
56
56
  "mocha": "12.0.0-beta-10",
57
57
  "moment": "2.30.1",
@@ -64,7 +64,7 @@
64
64
  "tstyche": "^7.0.0",
65
65
  "typescript": "5.9.3",
66
66
  "typescript-eslint": "^8.31.1",
67
- "uuid": "14.0.0",
67
+ "uuid": "14.0.1",
68
68
  "xss": "1.0.15"
69
69
  },
70
70
  "directories": {
package/types/index.d.ts CHANGED
@@ -191,11 +191,13 @@ declare module 'mongoose' {
191
191
  Document<unknown, TQueryHelpers, RawDocType, TVirtuals, TSchemaOptions> & Default__v<Require_id<HydratedDocPathsType>, TSchemaOptions>,
192
192
  Document<unknown, TQueryHelpers, RawDocType, TVirtuals, TSchemaOptions> & MergeType<
193
193
  Default__v<Require_id<HydratedDocPathsType>, TSchemaOptions>,
194
- IfEquals<
195
- TOverrides,
196
- {},
197
- TOverrides,
198
- TOverrides & AddDefaultId<HydratedDocPathsType, TVirtuals, TSchemaOptions>
194
+ HydratedDocumentOverrides<
195
+ IfEquals<
196
+ TOverrides,
197
+ {},
198
+ TOverrides,
199
+ TOverrides & AddDefaultId<HydratedDocPathsType, TVirtuals, TSchemaOptions>
200
+ >
199
201
  >
200
202
  >
201
203
  >
package/types/models.d.ts CHANGED
@@ -193,7 +193,7 @@ declare module 'mongoose' {
193
193
  * - vanilla arrays of POJOs for document arrays
194
194
  * - POJOs and array of arrays for maps
195
195
  */
196
- type CreateObjectWithExtraKeys<T> = T & Record<string, unknown>;
196
+ type CreateObjectWithExtraKeys<T> = T | (T & Record<string, unknown>);
197
197
  type ApplyBasicCreateCasting<T> = {
198
198
  [K in keyof T]: NonNullable<T[K]> extends Map<infer KeyType extends string, infer ValueType>
199
199
  ? (Record<KeyType, ValueType> | Array<[KeyType, ValueType]> | T[K] | QueryTypeCasting<Extract<T[K], TreatAsPrimitives>>)
@@ -161,6 +161,15 @@ declare module 'mongoose' {
161
161
  : T[K];
162
162
  };
163
163
 
164
+ type OmitThisParameterIfFunction<T> = T extends (...args: any[]) => any ? OmitThisParameter<T> : T;
165
+
166
+ // Strip explicit `this` parameter from methods in schema type options. The `this` parameter
167
+ // is just for type-checking the function body. Keeping the explicit 'this' typing can cause
168
+ // compiler errors on the method calls, so remove it for the hydrated document definition.
169
+ type HydratedDocumentOverrides<T> = {
170
+ [K in keyof T]: OmitThisParameterIfFunction<T[K]>;
171
+ };
172
+
164
173
  /**
165
174
  * @summary Adds timestamp fields to a type
166
175
  * @description Adds createdAt and updatedAt fields of type Date, or custom timestamp fields if specified