This contains a dictionary of the supported Tyranid types.
Type
Also known as "Domain".
The default built-in types are:
- array
- bitmask
- boolean
- date
- datetime
- double
- image
- integer
- link
- mongoid
- object
- password
- s3
- string
- time
- uid
- url
See Field.def for information on type-specific Field options.
When creating your own types, they will get automatically registered with Tyranid via the new Tyr.Type() constructor.
static
instance
This compares two values of this type and returns a negative (a < b), zero (a == b), or positive (a > b) number suitable for sorting comparators.
Any schema validation can be done inside this method. For example, ArrayTypes verify that the field has a valid "of" property.
This creates a new value for the given type. Usually this will return undefined but if
there is a defaultValue specified for the field, then that value will be returned.
This can also be useful if a custom type needs to have a certain structure guaranteed to be present.
This defines the structure of a type and is the argument that is passed into the Type constructor when you want to define your own types.
In the table below, TType refers to the TypeScript type for this Type.
Object Structure | Type | Default | Notes | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{ | ||||||||||||||||||||
compare: | (field: Field, a: TType, b: TType) => number | Comparator to use for members of this type. Must be isomorphic. | ||||||||||||||||||
compile: | (compiler, field: Field) => void | Callback called when parsing fields using your type. This should be used to validate any properties that your type adds to Fields. | ||||||||||||||||||
fromClient: | (field: Field, value: string) => TType | Method used to when reading values from the client onto the server. | ||||||||||||||||||
fromString: | (s: string) => TType | Comparator to use for members of this type. Must be isomorphic. | ||||||||||||||||||
format: | (field: Field, value: TType) => string | Method used to convert values of this Type to a display string. | ||||||||||||||||||
matches: | (path: Path, where, document: Document) => boolean | Returns whether this type matches the given where clause. | ||||||||||||||||||
name: | string | required | The name of this type. | |||||||||||||||||
query: | (path: Path, where, query: Mongo query) => void | Applies any where clause set on a Field for this type. | ||||||||||||||||||
typescript: | string | The name of the TypeScript type to use for this type (this defines TType).
validate: | (field: Field, value: string) => void |
| This method should throw a UserError if this field does not validate.
| width: | integer |
| This provides the default width in pixels for fields of this type when displayed in a table.
| Developer Documentation
| note: | string | none | Contains developer-facing documentation about this type (only visible in the Tyranid console).
| } |
|
This method will be used by Tyranid to coerce strings to this data type.
This method will be used by Tyranid to convert incoming data from the client into server objects. For example, MongoId types will convert client-side MongoID strings into server-side ObjectId objects.
This method will be used by Tyranid to convert incoming query data from the client into server query objects. For example, MongoId types will convert client-side MongoID strings into server-side ObjectId objects.
This returns a formatted version of this value for display.
This returns true if the given doc's property given by path matches the where.
Contains the name of this type.
This updates the passed in MongoDB-style query with the given where.
This returns the sortValue to use in sorting comparisons.
This method will be used by Tyranid to convert server data into JSON suitable for the client. For example, MongoId types will convert server-side ObjectIds into client-side MongoID strings.
This is used by Tyranid to validate fields of this type.
This returns the default with for this fields of this type when displayed in a table.