WWDC WEEK
SALE
30
%
off
Subscribe now
WWDC WEEK
SALE
30
%
off
Subscribe now

Modern Persistence: Advanced Aggregations

Episode #328 • Jun 16, 2025 • Subscriber-Only

We conclude our series on “modern persistence” with advanced queries that leverage reusable SQL builders, “safe” SQL strings, and complex aggregations, including JSON arrays and a query that selects many stats in a single query.

Previous episode
Modern Persistence: Advanced Aggregations
Locked

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Sign in with GitHub

Introduction

Stephen

Alright, our remake of Apple’s reminder app is really starting to take shape. We now have a root collection of all the reminders lists in our app. We can create a new list or delete any of our lists if we want. Then we can tap a list to drill down into that list and see all the reminders associated with it. And in that detail we are able to sort and filter the lists, and those settings are even saved on a per list basis. And finally, we are able to create new reminders, update existing reminders, as well as delete reminders.

Brandon

It’s all looking great, but there are just a few more final touches we want to put on the app before ending this series. There are still some placeholders left throughout our views representing functionality that we haven’t yet figured out. There are some complex computations we haven’t dealt with, such as calculating all of the top-level stats at the root of the app. There are also some complex interactions with tags that aren’t implemented. That will give us our first exposure to many-to-many relationships, which is something that can be quite difficult to get right in SwiftData.

And we will get to all of that in due time, but we are going to start with something a bit easier. Right now we have a placeholder in our view for calculating the “past due” state for our reminders. You might typically think that is something that should be computed in app code, but we want to show that it is actually really great for us to leave that computation to SQLite. And this will give us our first exposure into building little reusable SQL helpers that can be pieced together in any query.

Let’s dig in.

Query reuse: past-due


References

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 72 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing