Handling empty relationship column the same way other columns are handled, it won't do anything until it is valid - but doesn't error.
This commit is contained in:
parent
352ff82885
commit
1dea4f24b7
|
@ -234,8 +234,16 @@ class LinkController {
|
|||
for (let fieldName of Object.keys(schema)) {
|
||||
const field = schema[fieldName]
|
||||
if (field.type === "link") {
|
||||
// handle this in a separate try catch, want
|
||||
// the put to bubble up as an error, if can't update
|
||||
// table for some reason
|
||||
let linkedModel
|
||||
try {
|
||||
linkedModel = await this._db.get(field.modelId)
|
||||
} catch (err) {
|
||||
continue
|
||||
}
|
||||
// create the link field in the other model
|
||||
const linkedModel = await this._db.get(field.modelId)
|
||||
linkedModel.schema[field.fieldName] = {
|
||||
name: field.fieldName,
|
||||
type: "link",
|
||||
|
|
|
@ -42,6 +42,7 @@ exports.updateLinks = async function({
|
|||
model,
|
||||
oldModel,
|
||||
}) {
|
||||
const baseReturnObj = record == null ? model : record
|
||||
if (instanceId == null) {
|
||||
throw "Cannot operate without an instance ID."
|
||||
}
|
||||
|
@ -50,12 +51,16 @@ exports.updateLinks = async function({
|
|||
arguments[0].modelId = model._id
|
||||
}
|
||||
let linkController = new LinkController(arguments[0])
|
||||
if (
|
||||
!(await linkController.doesModelHaveLinkedFields()) &&
|
||||
(oldModel == null ||
|
||||
!(await linkController.doesModelHaveLinkedFields(oldModel)))
|
||||
) {
|
||||
return record
|
||||
try {
|
||||
if (
|
||||
!(await linkController.doesModelHaveLinkedFields()) &&
|
||||
(oldModel == null ||
|
||||
!(await linkController.doesModelHaveLinkedFields(oldModel)))
|
||||
) {
|
||||
return baseReturnObj
|
||||
}
|
||||
} catch (err) {
|
||||
return baseReturnObj
|
||||
}
|
||||
switch (eventType) {
|
||||
case EventType.RECORD_SAVE:
|
||||
|
|
Loading…
Reference in New Issue