surface schema for user in json

This commit is contained in:
Peter Clement 2021-10-12 12:20:40 +01:00
parent e479ced4c8
commit 2d4bb78afc
1 changed files with 15 additions and 3 deletions

View File

@ -11,10 +11,22 @@
export let value export let value
export let bindings export let bindings
$: table = $tables.list.find(table => table._id === value?.tableId) let table
$: schemaFields = Object.entries(table?.schema ?? {}) let schemaFields
$: {
table = $tables.list.find(table => table._id === value?.tableId)
schemaFields = Object.entries(table?.schema ?? {})
// surface the schema so the user can see it in the json
schemaFields.map(([, schema]) => {
if (!schema.autocolumn && !value[schema.name]) {
value[schema.name] = ""
}
})
}
const onChangeTable = e => { const onChangeTable = e => {
value = { tableId: e.detail } value["tableId"] = e.detail
dispatch("change", value) dispatch("change", value)
} }