mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
[@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:
committed by
Nathan Shively-Sanders
parent
800fe54715
commit
49846d93c2
Vendored
+4
-2
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user