1-n-data-integrity

This commit is contained in:
Martin McKeaveney 2021-02-25 11:05:15 +00:00
parent 8e0aaf0daa
commit 19fb11e69d
1 changed files with 8 additions and 0 deletions

View File

@ -132,6 +132,14 @@ class LinkController {
const rowField = row[fieldName]
const field = table.schema[fieldName]
if (field.type === FieldTypes.LINK && rowField != null) {
// if 1:N, ensure that this ID is not already attached to another record
const linkedTable = await this._db.get(field.tableId)
const linkedSchema = linkedTable.schema[field.fieldName]
if (linkedSchema.relationshipType === "one-to-many") {
}
// check which links actual pertain to the update in this row
const thisFieldLinkDocs = linkDocs.filter(
linkDoc =>