| 744 | } |
| 745 | |
| 746 | async applyPatchUpdate (baseGraph, updates, uri, contentType) { |
| 747 | const patchedGraph = baseGraph |
| 748 | |
| 749 | for (const update of updates) { |
| 750 | if (update.operation === 'delete') { |
| 751 | const deleteQuads = this.parseQuads(update.where, uri, contentType) |
| 752 | for (const quad of deleteQuads) { |
| 753 | patchedGraph.removeMatches(quad.subject, quad.predicate, quad.object) |
| 754 | } |
| 755 | } else if (update.operation === 'insert') { |
| 756 | const insertQuads = this.parseQuads(update.quads, uri, contentType) |
| 757 | for (const quad of insertQuads) { |
| 758 | patchedGraph.add(quad.subject, quad.predicate, quad.object) |
| 759 | } |
| 760 | } else { |
| 761 | throw error(422, 'Unknown patch operation: ' + update.operation) |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | return patchedGraph |
| 766 | } |
| 767 | |
| 768 | async applyPatchInsertDelete (baseGraph, patchObject, uri, contentType) { |
| 769 | const patchedGraph = baseGraph |