mongoose 8.16.4 → 8.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/document.js CHANGED
@@ -2703,6 +2703,10 @@ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip, isNestedValidate
2703
2703
  if (!doc.$__isSelected(path) && !doc.$isModified(path)) {
2704
2704
  return false;
2705
2705
  }
2706
+ if (path.endsWith('.$*')) {
2707
+ // Skip $* paths - they represent map schemas, not actual document paths
2708
+ return false;
2709
+ }
2706
2710
  if (doc.$__.cachedRequired != null && path in doc.$__.cachedRequired) {
2707
2711
  return doc.$__.cachedRequired[path];
2708
2712
  }
package/lib/mongoose.js CHANGED
@@ -855,6 +855,17 @@ Mongoose.prototype.nextConnectionId;
855
855
 
856
856
  Mongoose.prototype.Aggregate = Aggregate;
857
857
 
858
+ /**
859
+ * The Base Mongoose Collection class. `mongoose.Collection` extends from this class.
860
+ *
861
+ * @memberOf Mongoose
862
+ * @instance
863
+ * @method Collection
864
+ * @api public
865
+ */
866
+
867
+ Mongoose.prototype.BaseCollection = require('./collection');
868
+
858
869
  /**
859
870
  * The Mongoose Collection constructor
860
871
  *
@@ -895,6 +906,17 @@ Object.defineProperty(Mongoose.prototype, 'Connection', {
895
906
  }
896
907
  });
897
908
 
909
+ /**
910
+ * The Base Mongoose Connection class. `mongoose.Connection` extends from this class.
911
+ *
912
+ * @memberOf Mongoose
913
+ * @instance
914
+ * @method Connection
915
+ * @api public
916
+ */
917
+
918
+ Mongoose.prototype.BaseConnection = require('./connection');
919
+
898
920
  /**
899
921
  * The Mongoose version
900
922
  *
@@ -649,6 +649,14 @@ function cast$elemMatch(val, context) {
649
649
  return val;
650
650
  }
651
651
 
652
+ /**
653
+ * Contains the handlers for different query operators for this schema type.
654
+ * For example, `$conditionalHandlers.$all` is the function Mongoose calls to cast `$all` filter operators.
655
+ *
656
+ * @property $conditionalHandlers
657
+ * @api public
658
+ */
659
+
652
660
  const handle = SchemaArray.prototype.$conditionalHandlers = {};
653
661
 
654
662
  handle.$all = cast$all;
@@ -185,6 +185,14 @@ const $conditionalHandlers = {
185
185
  $lte: handleSingle
186
186
  };
187
187
 
188
+ /**
189
+ * Contains the handlers for different query operators for this schema type.
190
+ * For example, `$conditionalHandlers.$in` is the function Mongoose calls to cast `$in` filter operators.
191
+ *
192
+ * @property $conditionalHandlers
193
+ * @api public
194
+ */
195
+
188
196
  Object.defineProperty(SchemaBigInt.prototype, '$conditionalHandlers', {
189
197
  enumerable: false,
190
198
  value: $conditionalHandlers
@@ -237,6 +237,14 @@ SchemaBoolean.prototype.cast = function(value) {
237
237
 
238
238
  const $conditionalHandlers = { ...SchemaType.prototype.$conditionalHandlers };
239
239
 
240
+ /**
241
+ * Contains the handlers for different query operators for this schema type.
242
+ * For example, `$conditionalHandlers.$in` is the function Mongoose calls to cast `$in` filter operators.
243
+ *
244
+ * @property $conditionalHandlers
245
+ * @api public
246
+ */
247
+
240
248
  Object.defineProperty(SchemaBoolean.prototype, '$conditionalHandlers', {
241
249
  enumerable: false,
242
250
  value: $conditionalHandlers
@@ -271,6 +271,14 @@ const $conditionalHandlers = {
271
271
  $lte: handleSingle
272
272
  };
273
273
 
274
+ /**
275
+ * Contains the handlers for different query operators for this schema type.
276
+ * For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
277
+ *
278
+ * @property $conditionalHandlers
279
+ * @api public
280
+ */
281
+
274
282
  Object.defineProperty(SchemaBuffer.prototype, '$conditionalHandlers', {
275
283
  enumerable: false,
276
284
  value: $conditionalHandlers
@@ -397,6 +397,14 @@ const $conditionalHandlers = {
397
397
  $lte: handleSingle
398
398
  };
399
399
 
400
+ /**
401
+ * Contains the handlers for different query operators for this schema type.
402
+ * For example, `$conditionalHandlers.$gte` is the function Mongoose calls to cast `$gte` filter operators.
403
+ *
404
+ * @property $conditionalHandlers
405
+ * @api public
406
+ */
407
+
400
408
  Object.defineProperty(SchemaDate.prototype, '$conditionalHandlers', {
401
409
  enumerable: false,
402
410
  value: $conditionalHandlers
@@ -222,6 +222,14 @@ const $conditionalHandlers = {
222
222
  $lte: handleSingle
223
223
  };
224
224
 
225
+ /**
226
+ * Contains the handlers for different query operators for this schema type.
227
+ * For example, `$conditionalHandlers.$lte` is the function Mongoose calls to cast `$lte` filter operators.
228
+ *
229
+ * @property $conditionalHandlers
230
+ * @api public
231
+ */
232
+
225
233
  Object.defineProperty(SchemaDecimal128.prototype, '$conditionalHandlers', {
226
234
  enumerable: false,
227
235
  value: $conditionalHandlers
@@ -116,7 +116,19 @@ SchemaDocumentArray.options = { castNonArrays: true };
116
116
  SchemaDocumentArray.prototype = Object.create(SchemaArray.prototype);
117
117
  SchemaDocumentArray.prototype.constructor = SchemaDocumentArray;
118
118
  SchemaDocumentArray.prototype.OptionsConstructor = SchemaDocumentArrayOptions;
119
- SchemaDocumentArray.prototype.$conditionalHandlers = { ...SchemaArray.prototype.$conditionalHandlers };
119
+
120
+ /**
121
+ * Contains the handlers for different query operators for this schema type.
122
+ * For example, `$conditionalHandlers.$size` is the function Mongoose calls to cast `$size` filter operators.
123
+ *
124
+ * @property $conditionalHandlers
125
+ * @api public
126
+ */
127
+
128
+ Object.defineProperty(SchemaDocumentArray.prototype, '$conditionalHandlers', {
129
+ enumerable: false,
130
+ value: { ...SchemaArray.prototype.$conditionalHandlers }
131
+ });
120
132
 
121
133
  /*!
122
134
  * ignore
@@ -205,6 +205,14 @@ const $conditionalHandlers = {
205
205
  $lte: handleSingle
206
206
  };
207
207
 
208
+ /**
209
+ * Contains the handlers for different query operators for this schema type.
210
+ * For example, `$conditionalHandlers.$lt` is the function Mongoose calls to cast `$lt` filter operators.
211
+ *
212
+ * @property $conditionalHandlers
213
+ * @api public
214
+ */
215
+
208
216
  Object.defineProperty(SchemaDouble.prototype, '$conditionalHandlers', {
209
217
  enumerable: false,
210
218
  value: $conditionalHandlers
@@ -209,6 +209,14 @@ const $conditionalHandlers = {
209
209
  $bitsAnySet: handleBitwiseOperator
210
210
  };
211
211
 
212
+ /**
213
+ * Contains the handlers for different query operators for this schema type.
214
+ * For example, `$conditionalHandlers.$gt` is the function Mongoose calls to cast `$gt` filter operators.
215
+ *
216
+ * @property $conditionalHandlers
217
+ * @api public
218
+ */
219
+
212
220
  Object.defineProperty(SchemaInt32.prototype, '$conditionalHandlers', {
213
221
  enumerable: false,
214
222
  value: $conditionalHandlers
@@ -413,6 +413,14 @@ const $conditionalHandlers = {
413
413
  $mod: handleArray
414
414
  };
415
415
 
416
+ /**
417
+ * Contains the handlers for different query operators for this schema type.
418
+ * For example, `$conditionalHandlers.$gte` is the function Mongoose calls to cast `$gte` filter operators.
419
+ *
420
+ * @property $conditionalHandlers
421
+ * @api public
422
+ */
423
+
416
424
  Object.defineProperty(SchemaNumber.prototype, '$conditionalHandlers', {
417
425
  enumerable: false,
418
426
  value: $conditionalHandlers
@@ -268,6 +268,14 @@ const $conditionalHandlers = {
268
268
  $lte: handleSingle
269
269
  };
270
270
 
271
+ /**
272
+ * Contains the handlers for different query operators for this schema type.
273
+ * For example, `$conditionalHandlers.$in` is the function Mongoose calls to cast `$in` filter operators.
274
+ *
275
+ * @property $conditionalHandlers
276
+ * @api public
277
+ */
278
+
271
279
  Object.defineProperty(SchemaObjectId.prototype, '$conditionalHandlers', {
272
280
  enumerable: false,
273
281
  value: $conditionalHandlers
@@ -660,6 +660,14 @@ const $conditionalHandlers = {
660
660
  $not: handleSingle
661
661
  };
662
662
 
663
+ /**
664
+ * Contains the handlers for different query operators for this schema type.
665
+ * For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
666
+ *
667
+ * @property $conditionalHandlers
668
+ * @api public
669
+ */
670
+
663
671
  Object.defineProperty(SchemaString.prototype, '$conditionalHandlers', {
664
672
  enumerable: false,
665
673
  value: $conditionalHandlers
@@ -117,6 +117,11 @@ function _createConstructor(schema, baseClass, options) {
117
117
  return _embedded;
118
118
  }
119
119
 
120
+ /*!
121
+ * ignore
122
+ */
123
+ const $conditionalHandlers = { ...SchemaType.prototype.$conditionalHandlers };
124
+
120
125
  /**
121
126
  * Special case for when users use a common location schema to represent
122
127
  * locations for use with $geoWithin.
@@ -126,7 +131,7 @@ function _createConstructor(schema, baseClass, options) {
126
131
  * @api private
127
132
  */
128
133
 
129
- SchemaSubdocument.prototype.$conditionalHandlers.$geoWithin = function handle$geoWithin(val, context) {
134
+ $conditionalHandlers.$geoWithin = function handle$geoWithin(val, context) {
130
135
  return { $geometry: this.castForQuery(null, val.$geometry, context) };
131
136
  };
132
137
 
@@ -134,19 +139,32 @@ SchemaSubdocument.prototype.$conditionalHandlers.$geoWithin = function handle$ge
134
139
  * ignore
135
140
  */
136
141
 
137
- SchemaSubdocument.prototype.$conditionalHandlers.$near =
138
- SchemaSubdocument.prototype.$conditionalHandlers.$nearSphere = geospatial.cast$near;
142
+ $conditionalHandlers.$near =
143
+ $conditionalHandlers.$nearSphere = geospatial.cast$near;
139
144
 
140
- SchemaSubdocument.prototype.$conditionalHandlers.$within =
141
- SchemaSubdocument.prototype.$conditionalHandlers.$geoWithin = geospatial.cast$within;
145
+ $conditionalHandlers.$within =
146
+ $conditionalHandlers.$geoWithin = geospatial.cast$within;
142
147
 
143
- SchemaSubdocument.prototype.$conditionalHandlers.$geoIntersects =
148
+ $conditionalHandlers.$geoIntersects =
144
149
  geospatial.cast$geoIntersects;
145
150
 
146
- SchemaSubdocument.prototype.$conditionalHandlers.$minDistance = castToNumber;
147
- SchemaSubdocument.prototype.$conditionalHandlers.$maxDistance = castToNumber;
151
+ $conditionalHandlers.$minDistance = castToNumber;
152
+ $conditionalHandlers.$maxDistance = castToNumber;
153
+
154
+ $conditionalHandlers.$exists = $exists;
155
+
156
+ /**
157
+ * Contains the handlers for different query operators for this schema type.
158
+ * For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
159
+ *
160
+ * @property $conditionalHandlers
161
+ * @api public
162
+ */
148
163
 
149
- SchemaSubdocument.prototype.$conditionalHandlers.$exists = $exists;
164
+ Object.defineProperty(SchemaSubdocument.prototype, '$conditionalHandlers', {
165
+ enumerable: false,
166
+ value: $conditionalHandlers
167
+ });
150
168
 
151
169
  /**
152
170
  * Casts contents
@@ -258,6 +258,14 @@ const $conditionalHandlers = {
258
258
  $nin: handleArray
259
259
  };
260
260
 
261
+ /**
262
+ * Contains the handlers for different query operators for this schema type.
263
+ * For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
264
+ *
265
+ * @property $conditionalHandlers
266
+ * @api public
267
+ */
268
+
261
269
  Object.defineProperty(SchemaUUID.prototype, '$conditionalHandlers', {
262
270
  enumerable: false,
263
271
  value: $conditionalHandlers
package/lib/schemaType.js CHANGED
@@ -1638,8 +1638,12 @@ function handle$in(val, context) {
1638
1638
  });
1639
1639
  }
1640
1640
 
1641
- /*!
1642
- * ignore
1641
+ /**
1642
+ * Contains the handlers for different query operators for this schema type.
1643
+ * For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
1644
+ *
1645
+ * @property $conditionalHandlers
1646
+ * @api public
1643
1647
  */
1644
1648
 
1645
1649
  SchemaType.prototype.$conditionalHandlers = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "8.16.4",
4
+ "version": "8.17.0",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "bson": "^6.10.4",
24
24
  "kareem": "2.6.3",
25
- "mongodb": "~6.17.0",
25
+ "mongodb": "~6.18.0",
26
26
  "mpath": "0.9.0",
27
27
  "mquery": "5.0.0",
28
28
  "ms": "2.1.3",
@@ -4,7 +4,7 @@ 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
8
  [key: string]: any;
9
9
  }
10
10
 
@@ -21,6 +21,8 @@ declare module 'mongoose' {
21
21
  name: string;
22
22
  }
23
23
 
24
+ export type BaseCollection<T extends mongodb.Document> = CollectionBase<T>;
25
+
24
26
  /*
25
27
  * section drivers/node-mongodb-native/collection.js
26
28
  */
@@ -71,12 +71,18 @@ declare module 'mongoose' {
71
71
  };
72
72
  }[keyof SchemaMap];
73
73
 
74
+ export type BaseConnection = Connection;
75
+
74
76
  class Connection extends events.EventEmitter implements SessionStarter {
77
+ /** Runs a [db-level aggregate()](https://www.mongodb.com/docs/manual/reference/method/db.aggregate/) on this connection's underlying `db` */
75
78
  aggregate<ResultType = unknown>(pipeline?: PipelineStage[] | null, options?: AggregateOptions): Aggregate<Array<ResultType>>;
76
79
 
77
80
  /** Returns a promise that resolves when this connection successfully connects to MongoDB */
78
81
  asPromise(): Promise<this>;
79
82
 
83
+ /** The Mongoose instance this connection is associated with */
84
+ base: Mongoose;
85
+
80
86
  bulkWrite<TSchemaMap extends Record<string, AnyObject>>(
81
87
  ops: Array<ConnectionBulkWriteModel<TSchemaMap>>,
82
88
  options: mongodb.ClientBulkWriteOptions & { ordered: false }
@@ -18,7 +18,7 @@ declare module 'mongoose' {
18
18
  * * TQueryHelpers - Object with any helpers that should be mixed into the Query type
19
19
  * * DocType - the type of the actual Document created
20
20
  */
21
- class Document<T = unknown, TQueryHelpers = any, DocType = any, TVirtuals = Record<string, any>> {
21
+ class Document<T = unknown, TQueryHelpers = any, DocType = any, TVirtuals = Record<string, any>, TSchemaOptions = {}> {
22
22
  constructor(doc?: any);
23
23
 
24
24
  /** This documents _id. */
@@ -256,23 +256,23 @@ declare module 'mongoose' {
256
256
  set(value: string | Record<string, any>): this;
257
257
 
258
258
  /** The return value of this method is used in calls to JSON.stringify(doc). */
259
- toJSON(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals>>;
260
- toJSON(options?: ToObjectOptions & { flattenMaps?: true, flattenObjectIds?: false }): FlattenMaps<Default__v<Require_id<DocType>>>;
261
- toJSON(options: ToObjectOptions & { flattenObjectIds: false }): FlattenMaps<Default__v<Require_id<DocType>>>;
262
- toJSON(options: ToObjectOptions & { flattenObjectIds: true }): ObjectIdToString<FlattenMaps<Default__v<Require_id<DocType>>>>;
263
- toJSON(options: ToObjectOptions & { flattenMaps: false }): Default__v<Require_id<DocType>>;
264
- toJSON(options: ToObjectOptions & { flattenMaps: false; flattenObjectIds: true }): ObjectIdToString<Default__v<Require_id<DocType>>>;
265
-
266
- toJSON<T = Default__v<Require_id<DocType>>>(options?: ToObjectOptions & { flattenMaps?: true, flattenObjectIds?: false }): FlattenMaps<T>;
267
- toJSON<T = Default__v<Require_id<DocType>>>(options: ToObjectOptions & { flattenObjectIds: false }): FlattenMaps<T>;
268
- toJSON<T = Default__v<Require_id<DocType>>>(options: ToObjectOptions & { flattenObjectIds: true }): ObjectIdToString<FlattenMaps<T>>;
269
- toJSON<T = Default__v<Require_id<DocType>>>(options: ToObjectOptions & { flattenMaps: false }): T;
270
- toJSON<T = Default__v<Require_id<DocType>>>(options: ToObjectOptions & { flattenMaps: false; flattenObjectIds: true }): ObjectIdToString<T>;
259
+ toJSON(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals>, TSchemaOptions>;
260
+ toJSON(options?: ToObjectOptions & { flattenMaps?: true, flattenObjectIds?: false }): FlattenMaps<Default__v<Require_id<DocType>, TSchemaOptions>>;
261
+ toJSON(options: ToObjectOptions & { flattenObjectIds: false }): FlattenMaps<Default__v<Require_id<DocType>, TSchemaOptions>>;
262
+ toJSON(options: ToObjectOptions & { flattenObjectIds: true }): ObjectIdToString<FlattenMaps<Default__v<Require_id<DocType>, TSchemaOptions>>>;
263
+ toJSON(options: ToObjectOptions & { flattenMaps: false }): Default__v<Require_id<DocType>, TSchemaOptions>;
264
+ toJSON(options: ToObjectOptions & { flattenMaps: false; flattenObjectIds: true }): ObjectIdToString<Default__v<Require_id<DocType>, TSchemaOptions>>;
265
+
266
+ toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options?: ToObjectOptions & { flattenMaps?: true, flattenObjectIds?: false }): FlattenMaps<T>;
267
+ toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenObjectIds: false }): FlattenMaps<T>;
268
+ toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenObjectIds: true }): ObjectIdToString<FlattenMaps<T>>;
269
+ toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenMaps: false }): T;
270
+ toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenMaps: false, flattenObjectIds: true }): ObjectIdToString<T>;
271
271
 
272
272
  /** Converts this document into a plain-old JavaScript object ([POJO](https://masteringjs.io/tutorials/fundamentals/pojo)). */
273
- toObject(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals>>;
274
- toObject(options?: ToObjectOptions): Default__v<Require_id<DocType>>;
275
- toObject<T>(options?: ToObjectOptions): Default__v<Require_id<T>>;
273
+ toObject(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals>, TSchemaOptions>;
274
+ toObject(options?: ToObjectOptions): Default__v<Require_id<DocType>, TSchemaOptions>;
275
+ toObject<T>(options?: ToObjectOptions): Default__v<Require_id<T>, TSchemaOptions>;
276
276
 
277
277
  /** Clears the modified state on the specified path. */
278
278
  unmarkModified<T extends keyof DocType>(path: T): void;
package/types/index.d.ts CHANGED
@@ -91,7 +91,8 @@ declare module 'mongoose' {
91
91
  InferSchemaType<TSchema>,
92
92
  ObtainSchemaGeneric<TSchema, 'TVirtuals'> & ObtainSchemaGeneric<TSchema, 'TInstanceMethods'>,
93
93
  ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>,
94
- ObtainSchemaGeneric<TSchema, 'TVirtuals'>
94
+ ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
95
+ ObtainSchemaGeneric<TSchema, 'TSchemaOptions'>
95
96
  >,
96
97
  TSchema
97
98
  > & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;
@@ -139,7 +140,7 @@ declare module 'mongoose' {
139
140
  ? IfAny<U, T & { _id: Types.ObjectId }, T & Required<{ _id: U }>>
140
141
  : T & { _id: Types.ObjectId };
141
142
 
142
- export type Default__v<T> = T extends { __v?: infer U }
143
+ export type Default__v<T, TSchemaOptions = {}> = TSchemaOptions extends { versionKey: false } ? T : T extends { __v?: infer U }
143
144
  ? T
144
145
  : T & { __v: number };
145
146
 
@@ -148,17 +149,18 @@ declare module 'mongoose' {
148
149
  DocType,
149
150
  TOverrides = {},
150
151
  TQueryHelpers = {},
151
- TVirtuals = {}
152
+ TVirtuals = {},
153
+ TSchemaOptions = {}
152
154
  > = IfAny<
153
155
  DocType,
154
156
  any,
155
157
  TOverrides extends Record<string, never> ?
156
- Document<unknown, TQueryHelpers, DocType, TVirtuals> & Default__v<Require_id<DocType>> :
158
+ Document<unknown, TQueryHelpers, DocType, TVirtuals, TSchemaOptions> & Default__v<Require_id<DocType>, TSchemaOptions> :
157
159
  IfAny<
158
160
  TOverrides,
159
- Document<unknown, TQueryHelpers, DocType, TVirtuals> & Default__v<Require_id<DocType>>,
160
- Document<unknown, TQueryHelpers, DocType, TVirtuals> & MergeType<
161
- Default__v<Require_id<DocType>>,
161
+ Document<unknown, TQueryHelpers, DocType, TVirtuals, TSchemaOptions> & Default__v<Require_id<DocType>, TSchemaOptions>,
162
+ Document<unknown, TQueryHelpers, DocType, TVirtuals, TSchemaOptions> & MergeType<
163
+ Default__v<Require_id<DocType>, TSchemaOptions>,
162
164
  TOverrides
163
165
  >
164
166
  >
@@ -196,10 +198,11 @@ declare module 'mongoose' {
196
198
  >;
197
199
 
198
200
  export type HydratedDocumentFromSchema<TSchema extends Schema> = HydratedDocument<
199
- InferSchemaType<TSchema>,
200
- ObtainSchemaGeneric<TSchema, 'TInstanceMethods'> & ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
201
- ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>,
202
- ObtainSchemaGeneric<TSchema, 'TVirtuals'>
201
+ InferSchemaType<TSchema>,
202
+ ObtainSchemaGeneric<TSchema, 'TInstanceMethods'> & ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
203
+ ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>,
204
+ ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
205
+ ObtainSchemaGeneric<TSchema, 'TSchemaOptions'>
203
206
  >;
204
207
 
205
208
  export interface TagSet {
@@ -272,7 +275,7 @@ declare module 'mongoose' {
272
275
  ObtainDocumentType<any, RawDocType, ResolveSchemaOptions<TSchemaOptions>>,
273
276
  ResolveSchemaOptions<TSchemaOptions>
274
277
  >,
275
- THydratedDocumentType = HydratedDocument<FlatRecord<DocType>, TVirtuals & TInstanceMethods, {}, TVirtuals>
278
+ THydratedDocumentType = HydratedDocument<FlatRecord<DocType>, TVirtuals & TInstanceMethods, {}, TVirtuals, ResolveSchemaOptions<TSchemaOptions>>
276
279
  >
277
280
  extends events.EventEmitter {
278
281
  /**
@@ -370,6 +373,8 @@ declare module 'mongoose' {
370
373
  /** Returns a new schema that has the `paths` from the original schema, minus the omitted ones. */
371
374
  omit<T = this>(paths: string[], options?: SchemaOptions): T;
372
375
 
376
+ options: SchemaOptions;
377
+
373
378
  /** Gets/sets schema paths. */
374
379
  path<ResultType extends SchemaType = SchemaType<any, THydratedDocumentType>>(path: string): ResultType;
375
380
  path<pathGeneric extends keyof RawDocType>(path: pathGeneric): SchemaType<RawDocType[pathGeneric]>;
@@ -602,7 +607,7 @@ declare module 'mongoose' {
602
607
  | typeof Schema.Types.UUID;
603
608
 
604
609
 
605
- export type InferId<T> = T extends { _id?: any } ? T['_id'] : Types.ObjectId;
610
+ export type InferId<T> = mongodb.InferIdType<T>;
606
611
 
607
612
  export interface VirtualTypeOptions<HydratedDocType = Document, DocType = unknown> {
608
613
  /** If `ref` is not nullish, this becomes a populated virtual. */
@@ -897,11 +902,6 @@ declare module 'mongoose' {
897
902
 
898
903
  export type SchemaDefinitionType<T> = T extends Document ? Omit<T, Exclude<keyof Document, '_id' | 'id' | '__v'>> : T;
899
904
 
900
- /**
901
- * Helper to choose the best option between two type helpers
902
- */
903
- export type _pickObject<T1, T2, Fallback> = T1 extends false ? T2 extends false ? Fallback : T2 : T1;
904
-
905
905
  /* for ts-mongoose */
906
906
  export class mquery { }
907
907