The game here is to build your application tools on top of the library. Not to look in the library for a ready-made tool.
The sentence above is not what I wanted to say, @remcopoelstra. What I wanted to say was:
It's useful to distinguish three concepts:
- the acquisition of database values (from GRDB apis).
- the processing of database values (by your app).
- the actions that modify database values (through GRDB apis).
Your initial post shows you lost in a sea of various ways to acquire database values because none of them acquire actions (the deletions you are looking for).
The solutions I suggest have you use an acquisition tool you are already familiar with (the good old ValueObservation), and turn your problem into the processing of database values (spot values that turn missing).
As you can see, GRDB provides no way to observe actions directly (except with the low-level TransactionObserver protocol). Instead, it focuses on value acquisition and observation, because it's the strongest trend in application development in the recent years. Combine, SwiftUI, UITableViewDiffableDataSource, functional programming, focus on immutability, are all programming idioms that let applications process values, instead of handling actions.
A "deletion" is not observed directly. Instead, you process value changes in order to find deletions.
One can wonder if this is really easier .
Indeed, another advice could have been to send a deletion notification through NotificationCenter after objects were deleted. The problem with this solution, though, is twofold:
- You can not ask GRDB to post the deletion notification for you. If it would, then another user would ask for a notification for insertion, another one for the change of some column in some table, and another one... etc. "Action" is too general: there's no way to fulfill all needs.
- So you send the notification from application code. But now, if you forget, now or in the future, to post the notification in some place, or post an incorrect one, some windows won't get updated. That's a big burden on application maintenance.
That's why my best advice is to use the value observation techniques. Those never forget to notify a change. And you can infer actions from those changes. Deletions, but also all other kinds of diffs that your apps are interested in.