@ -21,7 +21,7 @@
try {
try {
// Create datasource
// Create datasource
await datasources.save(datasource)
await datasources.save(datasource)
notifications.success(`Datasource ${ name } sav ed successfully.`)
notifications.success(`Datasource ${ name } updat ed successfully.`)
unsaved = false
unsaved = false
} catch (err) {
} catch (err) {
notifications.error(`Error saving datasource: ${ err } `)
notifications.error(`Error saving datasource: ${ err } `)
@ -31,7 +31,7 @@
async function updateDatasourceSchema() {
async function updateDatasourceSchema() {
try {
try {
await datasources.updateSchema(datasource)
await datasources.updateSchema(datasource)
notifications.success(`Datasource ${ name } schema sav ed successfully.`)
notifications.success(`Datasource ${ name } tables updat ed successfully.`)
unsaved = false
unsaved = false
await tables.fetch()
await tables.fetch()
} catch (err) {
} catch (err) {
@ -44,6 +44,11 @@
$goto(`./${ query . _id } `)
$goto(`./${ query . _id } `)
}
}
function onClickTable(table) {
tables.select(table)
$goto(`../../table/${ table . _id } `)
}
function setUnsaved() {
function setUnsaved() {
unsaved = true
unsaved = true
}
}
@ -86,6 +91,27 @@
on:change={ setUnsaved }
on:change={ setUnsaved }
/>
/>
< / div >
< / div >
{ #if datasource . plus }
< Divider / >
< div class = "query-header" >
< Heading size = "S" > Tables< / Heading >
< Button primary on:click = { updateDatasourceSchema }
>Fetch Tables From Database< /Button
>
< / div >
< Body >
This datasource can determine tables automatically. Budibase can fetch your tables directly from the database and you can use them without having to write any queries at all.
< / Body >
< div class = "query-list" >
{ #each Object . keys ( datasource . entities ) as entity }
< div class = "query-list-item" on:click = {() => onClickTable ( datasource . entities [ entity ])} >
< p class = "query-name" > { entity } </ p >
< p > Primary Key: { datasource . entities [ entity ]. primary } </ p >
< p > →< / p >
< / div >
{ /each }
< / div >
{ /if }
< Divider / >
< Divider / >
< div class = "query-header" >
< div class = "query-header" >
< Heading size = "S" > Queries< / Heading >
< Heading size = "S" > Queries< / Heading >
@ -100,15 +126,6 @@
< / div >
< / div >
{ /each }
{ /each }
< / div >
< / div >
{ #if datasource . plus }
< Divider / >
< div class = "query-header" >
< Heading size = "S" > Queries< / Heading >
< Button cta on:click = { updateDatasourceSchema }
>Fetch Tables From Database< /Button
>
< / div >
{ /if }
< / Layout >
< / Layout >
< / section >
< / section >
{ /if }
{ /if }