HeapTableRepo.schema
JSON Schema of the fields in a heap table.
It provides a JSON schema object with fields described when declaring the table using Heap.Table.
It can be used to read metadata about the table fields and to generate, for example, automatic forms for editing table records considering the field types.
The schema does not include descriptions of system fields in the heap table, such as id
, heapType
, etc.
Usage/Signature
table.schema
- Return Value:
object
JSON schema of the object with the top-level fields of the table.
Examples
Outputting a list of table fields with their types.
const Tasks = Heap.Table('tasks', {
title: Heap.String(),
due: Heap.DateTime(),
basedOn: Heap.GenericLink(),
})
app.screen('task-fields', async ctx => {
return (
<screen title="Task Fields">
{Object.entries(Tasks.schema.properties).map(([fieldName, fieldSchema]) =>
<list-item
content={{
title: fieldName,
subTitle: fieldSchema.type,
}}
/>
)}
</screen>
)
})