An object providing the discriminator logic or a string/number
that will be stored into the _type
attribute.
Optional
parent: ClazzOrModelSchema<any>When there are multiple levels of hierarchy involved you may provide this argument to indicate the main schema used for deserialization. When not give the parent schema is inferred as the direct parent (the class/schema that is extended).
Generated using TypeDoc
Sometimes, when working with schema hierarchies, we may want to deserialize an object to a specific sub-schema. The
subSchema
decorator is used to handle such scenario. What schema is picked among those available is decided using a "discriminator". The discriminator can be a string (which is added to the serialized object) or a object containing callbacks allowing for more complex behaviour.Example
Example
Using the
parent
argument it's possible to specify the subschema parent instead of relying on auto-detention.Returns