New release: GRDB 3.4.0

(Gwendal Roué) #1

Hello Swift Community,

Version 3.4.0 is out, with a few bug fixes, and a new feature: association aggregates.

Associations let you describe relations between database Record types. They are type-safe, and backed by the underlying SQLite schema:

struct Team: TableRecord {
    let players = hasMany(Player.self)

struct Player: TableRecord {
    let team = belongsTo(Team.self)

Association Aggregates allow you to compute values out of associated records:

// Authors with the number of books they wrote
let request = Author.annotated(with: Author.books.count)

// Authors with their minimum and maximum book year
let request = Author.annotated(with:

// Authors who did not write any book
let request = Author.having(Author.books.isEmpty)

// Authors who wrote more books that they did paintings
let request = Author.having(Author.books.count > Author.paintings.count)

Release notes