Lookup Tables
Often times you need other related data, that is not explicitly specified in the configurator by the end user, to create something useful out of the user's choices.
For this purpose Konfoo provides lookup tables:
products:
unique:
code: Product Code
group:
tag: Tag
csv: |
"Product Code","Tag","Weight","Unit"
"MUG-001","mug","300.0","g"
"MUG-002","mug","400.0","g"
"MUG-003","mug","260.0","g"
"CLAY-2K","clay","2000.0","g"
"CLAY-10K","clay","10000.0","g"
To connect your file containing your table to your Konfoo project include it in the data
section of options
in your main domain definition file:
options:
data:
- products.yml
- math-constants.yml
# etc
You can include multiple files in the data
section and each file can contain multiple lookup tables. This allows you to keep related data together and have good structural organization across your project.
The names of the lookup tables must be unique within in one Konfoo project even if the tables are defined in different files.
Lookup indices
Lookup tables provide two types of lookup index:
- Unique - can only be set on a column that has unique values
- Group - can be set on any column and will group rows by identical values in that column
While the above example defines only one index of either kind you can define however many your particular table needs.
Derived fields
Lookup tables also provide a way to auto-fill choice
field options.
See more in the derived fields chapter.