adjustPostCount(of:by:on:)
func adjustPostCount(of fez: FriendlyFez, by delta: Int, on db: Database) async throws
Adds delta to the fez’s cached postCount with a single UPDATE ... SET post_count = post_count + delta, rather than writing back
a value computed in Swift, so concurrent posts and deletes can’t overwrite each other’s change. The updated row stays locked until the
surrounding transaction commits, which also serializes writers of the same fez. fez.postCount is set to the value the database now holds.
-
Declaration
Swift
struct PostCountRow : Decodable
View on GitHub