mongoschema.variant

This module provides a utility class to store different type values inside a single field. This can for example be used to model inheritance.

Members

Structs

SchemaVariant
struct SchemaVariant(Specs...)

Represents a data type which can hold different kinds of values but always exactly one or none at a time. Types is a list of types the variant can hold. By default type IDs are assigned from the stringof value which is the type name without module name. You can pass custom type names by passing a string following the type. Those will affect the type value in the serialized bson and the convenience access function names. Serializes the Bson as {"type": "T", "value": "my value here"}

Meta