We have now implemented a powerful syntax for representing joins in our query builder, and we are able to preserve the type information of each table involved so that we can write SELECT
, WHERE
and ORDER BY
clauses in a type-safe manner. It’s honestly pretty incredible how quickly we were able to get things working, and it’s all thanks to all of the infrastructure we’ve built in previous episodes, as well as the amazing parameter packs feature in modern Swift.
Let’s now push things even further. As we saw in last episode, the power of joins really starts to shine when it comes to aggregating data across joins. This is what allowed us to do things like selecting all lists from the database, along with a comma-separated list of the titles of reminders in each list. Another advanced query we previously considered was to select all lists from the database, along with a count of the reminders in each list.
Let’s see what it takes to write such advanced queries with our builder.