Skip to content

Embeddables

Embeddables are like entities, but do not have real tables or collection. They work like entities for validations and computed fields but cannot exist without entities. They are useful to create validated nested structures as JSON objects in relational table or as nested document in NoSQL collections. Embeddables can also refer to other embeddables.

Embeddable pincode

1
embeddables:
2
- name: pincode
3
fields:
4
- name: pincode
5
type: string
6
validations:
7
- type: required

Embeddable Address

1
embeddables:
2
- name: address
3
fields:
4
- name: firstline
5
type: string
6
validations:
7
- type: required
8
- name: secondline
9
type: string
10
- name: city
11
type: string
12
validations:
13
- type: required
14
- type: length
15
min: 3
16
max: 85
17
- name: code
18
type: string
19
validations:
20
- type: required
21
- type: regex
22
expression: ^\d{5}(?:[-\s]\d{4})?$
23
- name: country
24
type: string
25
validations:
26
- type: required
27
- name: pincode
28
type: pincode

Entity using Address

1
entities:
2
- name: person
3
inherits: kisai.id
4
fields:
5
- name: firstname
6
type: string
7
validations:
8
- type: length
9
max: 40
10
- name: middlename
11
type: string
12
validations:
13
- type: length
14
max: 40
15
- name: lastname
16
type: string
17
validations:
18
- type: length
19
max: 70
20
- name: address
21
type: address