Fixing record editting.

This commit is contained in:
mike12345567 2020-09-30 15:41:52 +01:00
parent 2bb349a381
commit 4f4298468a
1 changed files with 9 additions and 7 deletions

View File

@ -86,6 +86,15 @@ exports.save = async function(ctx) {
const existingRecord = record._rev && (await db.get(record._id))
// make sure link records are up to date
record = await linkRecords.updateLinks({
instanceId,
eventType: linkRecords.EventType.RECORD_SAVE,
record,
modelId: record.modelId,
model,
})
if (existingRecord) {
const response = await db.put(record)
record._rev = response.rev
@ -96,13 +105,6 @@ exports.save = async function(ctx) {
return
}
record = await linkRecords.updateLinks({
instanceId,
eventType: linkRecords.EventType.RECORD_SAVE,
record,
modelId: record.modelId,
model,
})
record.type = "record"
const response = await db.post(record)
record._rev = response.rev