[@types/mongoose] Allow the use of "DocumentArray.discriminator(name, schema, value)" (#39927)

* Allow the use of "DocumentArray.discriminator(name, schema, value)"

* Add test for signature change
This commit is contained in:
hasezoey
2019-11-04 16:31:05 -08:00
committed by Nathan Shively-Sanders
parent 800fe54715
commit 49846d93c2
2 changed files with 6 additions and 2 deletions
+4 -2
View File
@@ -2416,15 +2416,17 @@ declare module "mongoose" {
* Adds a discriminator type.
* @param name discriminator model name
* @param schema discriminator model schema
* @param value the string stored in the `discriminatorKey` property
*/
discriminator<U extends Document>(name: string, schema: Schema): Model<U>;
discriminator<U extends Document>(name: string, schema: Schema, value?: string): Model<U>;
/**
* Adds a discriminator type.
* @param name discriminator model name
* @param schema discriminator model schema
* @param value the string stored in the `discriminatorKey` property
*/
discriminator<U extends Document, M extends Model<U>>(name: string, schema: Schema): M;
discriminator<U extends Document, M extends Model<U>>(name: string, schema: Schema, value?: string): M;
}
+2
View File
@@ -1300,6 +1300,8 @@ mongoose.Schema.Types.DocumentArray.schemaName.toLowerCase();
documentarray.sparse(true);
/* http://thecodebarbarian.com/mongoose-4.8-embedded-discriminators */
documentarray.discriminator('name', new mongoose.Schema({ foo: String }));
/* https://mongoosejs.com/docs/api.html#documentarraypath_DocumentArrayPath-discriminator */
documentarray.discriminator('name2', new mongoose.Schema({ bar: String }), "circle");
/*
* section schema/number.js