Dynamic field types

A dynamic document field definition requires a specific field type. The field type determines how the field value is handled, displayed and stored.

A field type usually corresponds with a specific Java type.

Example

The following is an example with both simple fields and custom field types.

document-definition:
  name: person
  types:
    - id: street-name
      base-type: string
    - id: address
      base-type: fieldset
      fields:
        - id: street-name
          type: street-name
        - id: street-nr
          type: number
        - id: zipcode
          type: number
    - id: company
      base-type: fieldset
      fields:
        - id: name
          type: string
          label: Name
          text:
            description: Public company name
        - id: activities
          type: string[]
          possible-values:
            - building-software
            - selling-cars
            - destroying-houses
        - id: founded
          type: date
        - id: operational
          type: boolean
        - id: shareholders
          type: string
          possible-values:
            - private
            - public
  content:
    - id: firstname
      type: string
    - id: lastname
      type: string
    - id: phone-number
      type: string
    - id: email
      type: string
    - id: description
      type: text
    - id: address
      type: address
    - id: company
      type: company

Default type keys

The following type keys (for use in type or base-type) are available:

Type key Field type Description

string

Strings

Single-line text.

text

Strings

Multi-line text.

char

Strings

Single character.

number

Numbers

Whole number (Long).

number(byte)

Numbers

Whole number (Byte).

number(short)

Numbers

Whole number (Short).

number(integer)

Numbers

Whole number (Integer).

decimal

Numbers

Floating point number (BigDecimal) with 2 decimal points precision.

decimal(x)

Numbers

Floating point number (BigDecimal) with x decimal points precision, eg decimal(4).

currency(y)

Numbers

Floating point number (BigDecimal) with 2 decimal points precision with currency formatter for y, eg currency(EUR).

currency(y,x)

Numbers

Floating point number (BigDecimal) with x decimal points precision with currency formatter for y, eg currency(USD,4).

boolean

Boolean

Boolean (true/false) value.

date

Dates and Times

A date without a time-zone.

time

Dates and Times

A time without a time-zone.

datetime

Dates and Times

A date-time without a time-zone.

fieldset

Fieldset

Collection of nested fields.

@entity

Linked entity

Linked entity field (for example a User).

document

Linked document

References a DynamicDocument entity. The type specification is equal to @dynamicDocument.

document(hr:user)

Linked document

References a DynamicDocument for a definition user in the hr dataset.

document(hr:user/address)

Linked document

References a DynamicDocument for a definition address which has the user definition as its parent in the hr dataset.

document(hr:user@2)

Linked document

References a DynamicDocument for a definition user with version 2 in the hr dataset.

Enumerations

Several base types can be turned into an enumeration by specifying the possible-values. See the separate page for more information.

Custom types

The example shows the use of custom field types. The chapter on creating a custom type gives more information on how to to this.