🐛 only update tags if set in request (#1900)

* only update tags if set in request

* only create relations/sort if tags exist
This commit is contained in:
Mutasem Aldmour 2021-06-16 13:41:35 +03:00 committed by GitHub
parent 44c3e97621
commit 0b65459f9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -673,10 +673,13 @@ class App {
await WorkflowHelpers.validateWorkflow(updateData); await WorkflowHelpers.validateWorkflow(updateData);
await Db.collections.Workflow!.update(id, updateData).catch(WorkflowHelpers.throwDuplicateEntryError); await Db.collections.Workflow!.update(id, updateData).catch(WorkflowHelpers.throwDuplicateEntryError);
const tablePrefix = config.get('database.tablePrefix'); if (tags) {
await TagHelpers.removeRelations(req.params.id, tablePrefix); const tablePrefix = config.get('database.tablePrefix');
if (tags?.length) { await TagHelpers.removeRelations(req.params.id, tablePrefix);
await TagHelpers.createRelations(req.params.id, tags, tablePrefix);
if (tags.length) {
await TagHelpers.createRelations(req.params.id, tags, tablePrefix);
}
} }
// We sadly get nothing back from "update". Neither if it updated a record // We sadly get nothing back from "update". Neither if it updated a record