1
0
Fork 0
mirror of synced 2024-06-30 12:00:31 +12:00

definitions and tidy up

This commit is contained in:
Martin McKeaveney 2021-06-28 13:04:52 +01:00
parent 5cc3f6fbfb
commit e183a9e607
2 changed files with 23 additions and 23 deletions

View file

@ -2,19 +2,14 @@
import { RelationshipTypes } from "constants/backend"
import { Menu, MenuItem, MenuSection, Button, Input, Icon, ModalContent, RadioGroup, Heading } from "@budibase/bbui"
// "tasks_something": {
// "name": "tasks_something",
// "type": "link",
// "tableId": "whatever/othertable",
// "relationshipType": "one-to-many",
// },
export let save
export let datasource
export let from
export let tables
export let relationship = {}
let originalName = relationship.name
$: console.log(relationship)
$: valid = relationship.name && relationship.tableId && relationship.relationshipType
$: from = tables.find(table => table._id === relationship.source)
@ -43,24 +38,15 @@
// save the relationship on to the datasource
function saveRelationship() {
let key
// find the entity on the datasource
for (let entity in datasource.entities) {
// TODO: update with _id instead of name
if (relationship.from.name === entity) {
key = entity
}
}
datasource.entities[key].schema[relationship.name] = {
name: relationship.name,
datasource.entities[from.name].schema[relationship.name] = {
type: "link",
relationshipType: relationship.relationshipType,
tableId: relationship.to._id,
through: relationship.through
...relationship
}
if (originalName) {
// TODO: possible bug if you change name
delete datasource.entities[from.name][originalName]
}
save()
}
</script>

View file

@ -26,3 +26,17 @@ export interface Table {
primaryDisplay?: string
sourceId?: string
}
export interface BudibaseAppMetadata {
_id: string
_rev?: string
appId: string
type: string
version: string
componentlibraries: string[]
name: string
url: string
instance: { _id: string }
updatedAt: Date,
createdAt: Date
}