Merge branch 'feature/opinionated-sql' of github.com:Budibase/budibase into feature/opinionated-sql

This commit is contained in:
Martin McKeaveney 2021-06-18 12:05:32 +01:00
commit 0f840bbcc8
4 changed files with 74 additions and 13 deletions

View File

@ -37,7 +37,7 @@ Cypress.Commands.add("createApp", name => {
cy.contains("Create app").click()
})
.then(() => {
cy.contains("Budibase DB", {
cy.get(".selected > .content", {
timeout: 20000,
}).should("be.visible")
})
@ -51,7 +51,7 @@ Cypress.Commands.add("deleteApp", () => {
.then(val => {
console.log(val)
if (val.length > 0) {
cy.get(".hoverable > use").click()
cy.get(".title > :nth-child(3) > .spectrum-Icon").click()
cy.contains("Delete").click()
cy.get(".spectrum-Button--warning").click()
}
@ -72,7 +72,7 @@ Cypress.Commands.add("createTestTableWithData", () => {
Cypress.Commands.add("createTable", tableName => {
// Enter table name
cy.get("Budibase DB")
cy.contains("Budibase DB").click()
cy.contains("Create new table").click()
cy.get(".spectrum-Modal").within(() => {
cy.get("input").first().type(tableName).blur()

View File

@ -91,7 +91,7 @@
}
// Navigate to new table
$goto(`./table/${table._id}`)
$goto(`../../table/${table._id}`)
}
</script>

View File

@ -1,6 +1,9 @@
<script>
import { Button, Heading, Body, Layout, Modal } from "@budibase/bbui"
import { Button, Heading, Body, Layout, Modal, Divider } from "@budibase/bbui"
import CreateTableModal from "components/backend/TableNavigator/modals/CreateTableModal.svelte"
import ICONS from "components/backend/DatasourceNavigator/icons"
import { tables } from "stores/backend"
import { goto } from "@roxi/routify"
let modal
</script>
@ -9,10 +12,68 @@
<CreateTableModal />
</Modal>
<Layout>
<Heading>Budibase Internal DB</Heading>
<section>
<Layout>
<header>
<svelte:component
this={ICONS.BUDIBASE}
height="26"
width="26"
/>
<Heading size="M">Budibase Internal</Heading>
</header>
<Body size="S" grey lh>Budibase internal tables are part of your app, the data will be stored in your apps context.</Body>
<Divider />
<Heading size="S">Tables</Heading>
<div class="table-list">
{#each $tables.list.filter(table => table.type !== "external") as table}
<div class="table-list-item" on:click={$goto(`../../table/${table._id}`)}>
<Body size="S">{table.name}</Body>
{#if table.primaryDisplay}
<Body size="S">display column: {table.primaryDisplay}</Body>
{/if}
</div>
{/each}
</div>
<div>
<Button cta on:click={modal.show}>Create new table</Button>
</div>
</Layout>
</section>
<div>
<Button cta on:click={modal.show}>Create new table</Button>
</div>
</Layout>
<style>
section {
margin: 0 auto;
width: 640px;
}
header {
margin: 0 0 var(--spacing-xs) 0;
display: flex;
gap: var(--spacing-l);
align-items: center;
}
.table-list {
display: flex;
flex-direction: column;
gap: var(--spacing-m);
}
.table-list-item {
border-radius: var(--border-radius-m);
background: var(--background);
border: var(--border-dark);
display: grid;
grid-template-columns: 2fr 0.75fr 20px;
align-items: center;
padding: var(--spacing-m);
gap: var(--layout-xs);
transition: 200ms background ease;
}
.table-list-item:hover {
background: var(--grey-1);
cursor: pointer;
}
</style>

View File

@ -35,6 +35,7 @@ function outputProcessing(rows, table) {
}
row._id = generateRowIdField(idParts)
row.tableId = table._id
row._rev = "rev"
}
return rows
}
@ -176,7 +177,6 @@ exports.bulkDestroy = async ctx => {
const appId = ctx.appId
const { rows } = ctx.request.body
const tableId = ctx.params.tableId
// TODO: this can probably be optimised to a single SQL statement in the future
let promises = []
for (let row of rows) {
promises.push(
@ -232,7 +232,7 @@ exports.search = async ctx => {
sort,
paginate: {
limit: 1,
page: bookmark + 1,
page: (bookmark * limit) + 1,
}
})
hasNextPage = nextRows.length > 0