mongoose 6.3.5 → 6.3.6

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/lgtm.yml ADDED
@@ -0,0 +1,12 @@
1
+ path_classifiers:
2
+ src:
3
+ - lib
4
+ types:
5
+ - types
6
+ test:
7
+ - test
8
+ docs:
9
+ - docs
10
+ queries:
11
+ - exclude: "*"
12
+ - include: lib
package/lib/connection.js CHANGED
@@ -7,13 +7,13 @@
7
7
  const ChangeStream = require('./cursor/ChangeStream');
8
8
  const EventEmitter = require('events').EventEmitter;
9
9
  const Schema = require('./schema');
10
- const Collection = require('./driver').get().Collection;
11
10
  const STATES = require('./connectionstate');
12
11
  const MongooseError = require('./error/index');
13
12
  const SyncIndexesError = require('./error/syncIndexes');
14
13
  const PromiseProvider = require('./promise_provider');
15
14
  const ServerSelectionError = require('./error/serverSelection');
16
15
  const applyPlugins = require('./helpers/schema/applyPlugins');
16
+ const driver = require('./driver');
17
17
  const promiseOrCallback = require('./helpers/promiseOrCallback');
18
18
  const get = require('./helpers/get');
19
19
  const immediate = require('./helpers/immediate');
@@ -1026,6 +1026,7 @@ Connection.prototype.collection = function(name, options) {
1026
1026
  };
1027
1027
  options = Object.assign({}, defaultOptions, options ? utils.clone(options) : {});
1028
1028
  options.$wasForceClosed = this.$wasForceClosed;
1029
+ const Collection = driver.get().Collection;
1029
1030
  if (!(name in this.collections)) {
1030
1031
  this.collections[name] = new Collection(name, this, options);
1031
1032
  }
package/lib/document.js CHANGED
@@ -3474,8 +3474,8 @@ Document.prototype.$toObject = function(options, json) {
3474
3474
  defaultOptions = utils.options(defaultOptions, clone(schemaOptions[path] || {}));
3475
3475
 
3476
3476
  // If options do not exist or is not an object, set it to empty object
3477
- options = utils.isPOJO(options) ? clone(options) : {};
3478
- options._calledWithOptions = options._calledWithOptions || clone(options);
3477
+ options = utils.isPOJO(options) ? { ...options } : {};
3478
+ options._calledWithOptions = options._calledWithOptions || { ...options };
3479
3479
 
3480
3480
  let _minimize;
3481
3481
  if (options._calledWithOptions.minimize != null) {
@@ -3499,7 +3499,7 @@ Document.prototype.$toObject = function(options, json) {
3499
3499
  // `clone()` will recursively call `$toObject()` on embedded docs, so we
3500
3500
  // need the original options the user passed in, plus `_isNested` and
3501
3501
  // `_parentOptions` for checking whether we need to depopulate.
3502
- const cloneOptions = Object.assign(utils.clone(options), {
3502
+ const cloneOptions = Object.assign({}, options, {
3503
3503
  _isNested: true,
3504
3504
  json: json,
3505
3505
  minimize: _minimize,
@@ -4227,8 +4227,10 @@ Document.prototype.populate = function populate() {
4227
4227
  * @api public
4228
4228
  * @return {Array<Document>} array of populated documents. Empty array if there are no populated documents associated with this document.
4229
4229
  * @memberOf Document
4230
+ * @method $getPopulatedDocs
4230
4231
  * @instance
4231
4232
  */
4233
+
4232
4234
  Document.prototype.$getPopulatedDocs = function $getPopulatedDocs() {
4233
4235
  let keys = [];
4234
4236
  if (this.$__.populated != null) {
@@ -61,6 +61,8 @@ function applyTimestampsToChildren(now, update, schema) {
61
61
  if (createdAt != null) {
62
62
  subdoc[createdAt] = now;
63
63
  }
64
+
65
+ applyTimestampsToChildren(now, subdoc, $path.schema);
64
66
  });
65
67
  } else {
66
68
  if (updatedAt != null) {
@@ -69,6 +71,8 @@ function applyTimestampsToChildren(now, update, schema) {
69
71
  if (createdAt != null) {
70
72
  op[key][createdAt] = now;
71
73
  }
74
+
75
+ applyTimestampsToChildren(now, op[key], $path.schema);
72
76
  }
73
77
  }
74
78
  }
package/lib/index.js CHANGED
@@ -154,7 +154,7 @@ Mongoose.prototype.driver = driver;
154
154
  * mongoose.set('debug', function(collectionName, methodName, ...methodArgs) {}); // use custom function to log collection methods + arguments
155
155
  *
156
156
  * Currently supported options are:
157
- * - 'debug': If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all arugments passed to the method. For example, if you wanted to replicate the default logging, you could output from the callback `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`.
157
+ * - 'debug': If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all arguments passed to the method. For example, if you wanted to replicate the default logging, you could output from the callback `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`.
158
158
  * - 'returnOriginal': If `false`, changes the default `returnOriginal` option to `findOneAndUpdate()`, `findByIdAndUpdate`, and `findOneAndReplace()` to false. This is equivalent to setting the `new` option to `true` for `findOneAndX()` calls by default. Read our [`findOneAndUpdate()` tutorial](/docs/tutorials/findoneandupdate.html) for more information.
159
159
  * - 'bufferCommands': enable/disable mongoose's buffering mechanism for all connections and models
160
160
  * - 'cloneSchemas': false by default. Set to `true` to `clone()` all schemas before compiling into a model.
@@ -275,6 +275,7 @@ Mongoose.prototype.get = Mongoose.prototype.set;
275
275
  Mongoose.prototype.createConnection = function(uri, options, callback) {
276
276
  const _mongoose = this instanceof Mongoose ? this : mongoose;
277
277
 
278
+ const Connection = driver.get().getConnection();
278
279
  const conn = new Connection(_mongoose);
279
280
  if (typeof options === 'function') {
280
281
  callback = options;
package/lib/query.js CHANGED
@@ -124,7 +124,10 @@ function Query(conditions, options, model, collection) {
124
124
  }
125
125
 
126
126
  // inherit mquery
127
- mquery.call(this, this.mongooseCollection, options);
127
+ mquery.call(this, null, options);
128
+ if (collection) {
129
+ this.collection(collection);
130
+ }
128
131
 
129
132
  if (conditions) {
130
133
  this.find(conditions);
package/lib/schema/map.js CHANGED
@@ -69,6 +69,14 @@ class Map extends SchemaType {
69
69
  }
70
70
  }
71
71
 
72
+ /**
73
+ * This schema type's name, to defend against minifiers that mangle
74
+ * function names.
75
+ *
76
+ * @api public
77
+ */
78
+ Map.schemaName = 'Map';
79
+
72
80
  Map.prototype.OptionsConstructor = SchemaMapOptions;
73
81
 
74
82
  Map.defaultOptions = {};
@@ -9,6 +9,7 @@ const SchemaType = require('../schematype');
9
9
  const castObjectId = require('../cast/objectid');
10
10
  const getConstructorName = require('../helpers/getConstructorName');
11
11
  const oid = require('../types/objectid');
12
+ const isBsonType = require('../helpers/isBsonType');
12
13
  const utils = require('../utils');
13
14
 
14
15
  const CastError = SchemaType.CastError;
@@ -113,7 +114,7 @@ ObjectId.prototype.auto = function(turnOn) {
113
114
  * ignore
114
115
  */
115
116
 
116
- ObjectId._checkRequired = v => v instanceof oid;
117
+ ObjectId._checkRequired = v => isBsonType(v, 'ObjectID');
117
118
 
118
119
  /*!
119
120
  * ignore
@@ -161,7 +162,7 @@ ObjectId.cast = function cast(caster) {
161
162
  */
162
163
 
163
164
  ObjectId._defaultCaster = v => {
164
- if (!(v instanceof oid)) {
165
+ if (!(isBsonType(v, 'ObjectID'))) {
165
166
  throw new Error(v + ' is not an instance of ObjectId');
166
167
  }
167
168
  return v;
@@ -221,7 +222,7 @@ ObjectId.prototype.checkRequired = function checkRequired(value, doc) {
221
222
  */
222
223
 
223
224
  ObjectId.prototype.cast = function(value, doc, init) {
224
- if (!(value instanceof oid) && SchemaType._isRef(this, value, doc, init)) {
225
+ if (!(isBsonType(value, 'ObjectID')) && SchemaType._isRef(this, value, doc, init)) {
225
226
  // wait! we may need to cast this to a document
226
227
  if ((getConstructorName(value) || '').toLowerCase() === 'objectid') {
227
228
  return new oid(value.toHexString());
package/lib/schema.js CHANGED
@@ -473,9 +473,39 @@ Schema.prototype.defaultOptions = function(options) {
473
473
  return options;
474
474
  };
475
475
 
476
+ /**
477
+ * Inherit a Schema by applying a discriminator on an existing Schema.
478
+ *
479
+ *
480
+ * ####Example:
481
+ *
482
+ * const options = { discriminatorKey: 'kind' };
483
+ *
484
+ * const eventSchema = new mongoose.Schema({ time: Date }, options);
485
+ * const Event = mongoose.model('Event', eventSchema);
486
+ *
487
+ * // ClickedLinkEvent is a special type of Event that has
488
+ * // a URL.
489
+ * const ClickedLinkEvent = Event.discriminator('ClickedLink',
490
+ * new mongoose.Schema({ url: String }, options));
491
+ *
492
+ * // When you create a generic event, it can't have a URL field...
493
+ * const genericEvent = new Event({ time: Date.now(), url: 'google.com' });
494
+ * assert.ok(!genericEvent.url);
495
+ * // But a ClickedLinkEvent can
496
+ * const clickedEvent = new ClickedLinkEvent({ time: Date.now(), url: 'google.com' });
497
+ * assert.ok(clickedEvent.url);
498
+ *
499
+ * @param {String} name the name of the discriminator
500
+ * @param {Schema} schema the Schema of the discriminated Schema
501
+ * @return {Schema} the Schema instance
502
+ * @api public
503
+ */
504
+
476
505
  Schema.prototype.discriminator = function(name, schema) {
477
- this._applyDiscriminators = {};
478
- this._applyDiscriminators[name] = schema;
506
+ this._applyDiscriminators = Object.assign(this._applyDiscriminators || {}, { [name]: schema });
507
+
508
+ return this;
479
509
  };
480
510
 
481
511
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "6.3.5",
4
+ "version": "6.3.6",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -28,10 +28,9 @@
28
28
  "sift": "16.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "7.17.10",
32
- "@babel/preset-env": "7.17.10",
33
- "@typescript-eslint/eslint-plugin": "5.21.0",
34
- "@typescript-eslint/parser": "5.21.0",
31
+ "@babel/core": "7.18.2",
32
+ "@typescript-eslint/eslint-plugin": "5.27.0",
33
+ "@typescript-eslint/parser": "5.27.0",
35
34
  "acquit": "1.2.1",
36
35
  "acquit-ignore": "0.2.0",
37
36
  "acquit-require": "0.1.1",
@@ -41,31 +40,31 @@
41
40
  "benchmark": "2.1.4",
42
41
  "bluebird": "3.7.2",
43
42
  "buffer": "^5.6.0",
44
- "cheerio": "1.0.0-rc.10",
43
+ "cheerio": "1.0.0-rc.11",
45
44
  "crypto-browserify": "3.12.0",
46
45
  "dox": "0.3.1",
47
- "eslint": "8.14.0",
46
+ "eslint": "8.16.0",
48
47
  "eslint-plugin-mocha-no-only": "1.1.1",
49
48
  "highlight.js": "11.5.1",
50
49
  "lodash.isequal": "4.5.0",
51
50
  "lodash.isequalwith": "4.4.0",
52
- "marked": "4.0.14",
51
+ "marked": "4.0.16",
53
52
  "mkdirp": "^1.0.4",
54
53
  "mocha": "10.0.0",
55
54
  "moment": "2.x",
56
- "mongodb-memory-server": "8.5.2",
55
+ "mongodb-memory-server": "8.6.0",
57
56
  "ncp": "^2.0.0",
58
57
  "nyc": "15.1.0",
59
58
  "pug": "3.0.2",
60
59
  "q": "1.5.1",
61
60
  "serve-handler": "6.1.3",
62
- "sinon": "13.0.2",
61
+ "sinon": "14.0.0",
63
62
  "stream-browserify": "3.0.0",
64
63
  "ts-benchmark": "^1.0.2",
65
64
  "tsd": "0.20.0",
66
- "typescript": "4.6.4",
65
+ "typescript": "4.7.2",
67
66
  "uuid": "8.3.2",
68
- "webpack": "5.72.0"
67
+ "webpack": "5.72.1"
69
68
  },
70
69
  "directories": {
71
70
  "lib": "./lib/mongoose"
package/types/index.d.ts CHANGED
@@ -120,6 +120,17 @@ declare module 'mongoose' {
120
120
  useProjection?: boolean;
121
121
  }
122
122
 
123
+ export type DiscriminatorModel<M, T> = T extends Model<infer T1, infer T2, infer T3, infer T4>
124
+ ?
125
+ M extends Model<infer M1, infer M2, infer M3, infer M4>
126
+ ? Model<Omit<M1, keyof T1> & T1, M2 | T2, M3 | T3, M4 | T4>
127
+ : M
128
+ : M;
129
+
130
+ export type DiscriminatorSchema<DocType, M, TInstanceMethods, TQueryHelpers, TVirtuals, T> = T extends Schema<infer T1, infer T2, infer T3, infer T4, infer T5>
131
+ ? Schema<Omit<DocType, keyof T1> & T1, DiscriminatorModel<T2, M>, T3 | TInstanceMethods, T4 | TQueryHelpers, T5 | TVirtuals>
132
+ : Schema<DocType, M, TInstanceMethods, TQueryHelpers, TVirtuals>;
133
+
123
134
  export class Schema<DocType = any, M = Model<DocType, any, any, any>, TInstanceMethods = {}, TQueryHelpers = {}, TVirtuals = any> extends events.EventEmitter {
124
135
  /**
125
136
  * Create a new schema
@@ -142,6 +153,8 @@ declare module 'mongoose' {
142
153
  /** Returns a copy of this schema */
143
154
  clone<T = this>(): T;
144
155
 
156
+ discriminator<T extends Schema = Schema>(name: string, schema: T): DiscriminatorSchema<DocType, M, TInstanceMethods, TQueryHelpers, TVirtuals, T>;
157
+
145
158
  /** Returns a new schema that has the picked `paths` from this schema. */
146
159
  pick<T = this>(paths: string[], options?: SchemaOptions): T;
147
160
 
@@ -474,10 +487,10 @@ declare module 'mongoose' {
474
487
  type LeanTypeOrArray<T> = T extends unknown[] ? LeanArray<T> : LeanType<T>;
475
488
 
476
489
  export type LeanArray<T extends unknown[]> =
477
- // By checking if it extends Types.Array we can get the original base type before collapsing down,
478
- // rather than trying to manually remove the old types. This matches both Array and DocumentArray
490
+ // By checking if it extends Types.Array we can get the original base type before collapsing down,
491
+ // rather than trying to manually remove the old types. This matches both Array and DocumentArray
479
492
  T extends Types.Array<infer U> ? LeanTypeOrArray<U>[] :
480
- // If it isn't a custom mongoose type we fall back to "do our best"
493
+ // If it isn't a custom mongoose type we fall back to "do our best"
481
494
  T extends unknown[][] ? LeanArray<T[number]>[] : LeanType<T[number]>[];
482
495
 
483
496
  export type _LeanDocument<T> = {
package/types/models.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  declare module 'mongoose' {
2
2
  import mongodb = require('mongodb');
3
3
 
4
- export interface AcceptsDiscriminator {
4
+ export interface AcceptsDiscriminator<B> {
5
5
  /** Adds a discriminator type. */
6
- discriminator<D>(name: string | number, schema: Schema, value?: string | number | ObjectId): Model<D>;
6
+ discriminator<D>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<Omit<B, keyof D> & D>;
7
7
  discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string | number | ObjectId): U;
8
8
  }
9
9
 
@@ -116,7 +116,7 @@ declare module 'mongoose' {
116
116
  const Model: Model<any>;
117
117
  interface Model<T, TQueryHelpers = {}, TMethodsAndOverrides = {}, TVirtuals = {}> extends
118
118
  NodeJS.EventEmitter,
119
- AcceptsDiscriminator,
119
+ AcceptsDiscriminator<T>,
120
120
  IndexManager,
121
121
  SessionStarter {
122
122
  new <DocType = AnyKeys<T> & AnyObject>(doc?: DocType, fields?: any | null, options?: boolean | AnyObject): HydratedDocument<T, TMethodsAndOverrides, TVirtuals>;
@@ -416,4 +416,4 @@ declare module 'mongoose' {
416
416
  where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(obj: object): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
417
417
  where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
418
418
  }
419
- }
419
+ }
package/types/query.d.ts CHANGED
@@ -579,7 +579,7 @@ declare module 'mongoose' {
579
579
  snapshot(val?: boolean): this;
580
580
 
581
581
  /** Sets the sort order. If an object is passed, values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`. */
582
- sort(arg: string | { [key: string]: SortOrder }): this;
582
+ sort(arg?: string | { [key: string]: SortOrder | { $meta: 'textScore' } } | undefined | null): this;
583
583
 
584
584
  /** Sets the tailable option (for use with capped collections). */
585
585
  tailable(bool?: boolean, opts?: {
@@ -126,7 +126,7 @@ declare module 'mongoose' {
126
126
  transform?: (this: any, val: T) => any;
127
127
 
128
128
  /** defines a custom getter for this property using [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty). */
129
- get?: (value: any, doc?: this) => T;
129
+ get?: (value: any, doc?: this) => T | undefined;
130
130
 
131
131
  /** defines a custom setter for this property using [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty). */
132
132
  set?: (value: any, priorVal?: T, doc?: this) => any;
@@ -269,17 +269,17 @@ declare module 'mongoose' {
269
269
 
270
270
  namespace Schema {
271
271
  namespace Types {
272
- class Array extends SchemaType implements AcceptsDiscriminator {
272
+ class Array<B = any> extends SchemaType<B> implements AcceptsDiscriminator<B> {
273
273
  /** This schema type's name, to defend against minifiers that mangle function names. */
274
- static schemaName: string;
274
+ static schemaName: 'Array';
275
275
 
276
276
  static options: { castNonArrays: boolean; };
277
277
 
278
278
  discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string): U;
279
- discriminator<D>(name: string | number, schema: Schema, value?: string): Model<D>;
279
+ discriminator<D>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<Omit<B, keyof D> & D>;
280
280
 
281
281
  /** The schematype embedded in this array */
282
- caster?: SchemaType;
282
+ caster?: SchemaType<B>;
283
283
 
284
284
  /**
285
285
  * Adds an enum validator if this is an array of strings or numbers. Equivalent to
@@ -290,7 +290,7 @@ declare module 'mongoose' {
290
290
 
291
291
  class Boolean extends SchemaType {
292
292
  /** This schema type's name, to defend against minifiers that mangle function names. */
293
- static schemaName: string;
293
+ static schemaName: 'Boolean';
294
294
 
295
295
  /** Configure which values get casted to `true`. */
296
296
  static convertToTrue: Set<any>;
@@ -301,7 +301,7 @@ declare module 'mongoose' {
301
301
 
302
302
  class Buffer extends SchemaType {
303
303
  /** This schema type's name, to defend against minifiers that mangle function names. */
304
- static schemaName: string;
304
+ static schemaName: 'Buffer';
305
305
 
306
306
  /**
307
307
  * Sets the default [subtype](https://studio3t.com/whats-new/best-practices-uuid-mongodb/)
@@ -312,7 +312,7 @@ declare module 'mongoose' {
312
312
 
313
313
  class Date extends SchemaType {
314
314
  /** This schema type's name, to defend against minifiers that mangle function names. */
315
- static schemaName: string;
315
+ static schemaName: 'Date';
316
316
 
317
317
  /** Declares a TTL index (rounded to the nearest second) for _Date_ types only. */
318
318
  expires(when: number | string): this;
@@ -326,20 +326,20 @@ declare module 'mongoose' {
326
326
 
327
327
  class Decimal128 extends SchemaType {
328
328
  /** This schema type's name, to defend against minifiers that mangle function names. */
329
- static schemaName: string;
329
+ static schemaName: 'Decimal128';
330
330
  }
331
331
 
332
- class DocumentArray extends SchemaType implements AcceptsDiscriminator {
332
+ class DocumentArray<B = any> extends SchemaType<B> implements AcceptsDiscriminator<B> {
333
333
  /** This schema type's name, to defend against minifiers that mangle function names. */
334
- static schemaName: string;
334
+ static schemaName: 'DocumentArray';
335
335
 
336
336
  static options: { castNonArrays: boolean; };
337
337
 
338
- discriminator<D>(name: string | number, schema: Schema, value?: string): Model<D>;
338
+ discriminator<D>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<Omit<B, keyof D> & D>;
339
339
  discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string): U;
340
340
 
341
341
  /** The schema used for documents in this array */
342
- schema: Schema;
342
+ schema: Schema<B>;
343
343
 
344
344
  /** The constructor used for subdocuments in this array */
345
345
  caster?: typeof Types.Subdocument;
@@ -347,17 +347,17 @@ declare module 'mongoose' {
347
347
 
348
348
  class Map extends SchemaType {
349
349
  /** This schema type's name, to defend against minifiers that mangle function names. */
350
- static schemaName: string;
350
+ static schemaName: 'Map';
351
351
  }
352
352
 
353
353
  class Mixed extends SchemaType {
354
354
  /** This schema type's name, to defend against minifiers that mangle function names. */
355
- static schemaName: string;
355
+ static schemaName: 'Mixed';
356
356
  }
357
357
 
358
358
  class Number extends SchemaType {
359
359
  /** This schema type's name, to defend against minifiers that mangle function names. */
360
- static schemaName: string;
360
+ static schemaName: 'Number';
361
361
 
362
362
  /** Sets a enum validator */
363
363
  enum(vals: number[]): this;
@@ -371,26 +371,26 @@ declare module 'mongoose' {
371
371
 
372
372
  class ObjectId extends SchemaType {
373
373
  /** This schema type's name, to defend against minifiers that mangle function names. */
374
- static schemaName: string;
374
+ static schemaName: 'ObjectId';
375
375
 
376
376
  /** Adds an auto-generated ObjectId default if turnOn is true. */
377
377
  auto(turnOn: boolean): this;
378
378
  }
379
379
 
380
- class Subdocument extends SchemaType implements AcceptsDiscriminator {
380
+ class Subdocument<B = any> extends SchemaType<B> implements AcceptsDiscriminator<B> {
381
381
  /** This schema type's name, to defend against minifiers that mangle function names. */
382
382
  static schemaName: string;
383
383
 
384
384
  /** The document's schema */
385
- schema: Schema;
385
+ schema: Schema<B>;
386
386
 
387
387
  discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string): U;
388
- discriminator<D>(name: string | number, schema: Schema, value?: string): Model<D>;
388
+ discriminator<D>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<Omit<B, keyof D> & D>;
389
389
  }
390
390
 
391
391
  class String extends SchemaType {
392
392
  /** This schema type's name, to defend against minifiers that mangle function names. */
393
- static schemaName: string;
393
+ static schemaName: 'String';
394
394
 
395
395
  /** Adds an enum validator */
396
396
  enum(vals: string[] | any): this;
package/.lgtm.yml DELETED
@@ -1,3 +0,0 @@
1
- path_classifiers:
2
- test:
3
- - lib