Skip to content
Talk to our solutions team

Enums

Enums, short for “enumerations,” are a data type in many programming languages that consist of a set of named values called elements or members. These named values represent fixed, distinct, and related items within a collection, making the code more readable and maintainable by providing meaningful names instead of numeric or string literals.

Here enums allow developers to define list of values. Entities can have one more fields with data type as enum. A table is created for each enumeration with id and string value. The entity table will have the id of the enum instead of the string value.

# enum for week days
enums:
- name: weekdays
values:
- value: Sunday
- value: Monday
- value: Tuesday
- value: Wednesday
- value: Thursday
- value: Friday
- value: Saturday
enums:
- name: contenttype
values:
- value: text
- value: html
- value: markdown
- name: reaction
values:
- value: Like
- value: Celebrate
- value: Support
- value: Love
- value: Insightful

contenttype

id | value | createdby | createdon | updatedby | updatedon | deletedby | deletedon
----+----------+-------------+------------------------+-------------+------------------------+-----------+-----------
1 | text | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
2 | html | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
3 | markdown | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
(3 rows)

reaction

id | value | createdby | createdon | updatedby | updatedon | deletedby | deletedon
----+------------+-------------+------------------------+-------------+------------------------+-----------+-----------
1 | Like | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
2 | Celebrate | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
3 | Support | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
4 | Love | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
5 | Insightful | dataservice | 2024-02-22 13:56:40+00 | dataservice | 2024-02-22 13:56:40+00 | |
(5 rows)