Flutter Isar Database — part 5 — Advanced Querying

Tomic Riedel
5 min readAug 25, 2022

In the last article, we dealt with how to filter the data we query. Today we will look at advanced querying. This includes 8 topics that we will discover today. Bigger topics are sorting, unique values, and offsets & limits.

If you are new to this series, check out this list.

You can find the whole source code provided in this article here.

Happy reading!

Sorting

Okay, let’s first take a look at sorting. There are four methods to sort your results: .sortBy(), .sortByDesc(), .thenBy() and .thenByDesc(). SortBy… means, that you first sort by this value. If two of them are equal (Let’s say you have two times the same shoe model in your database), then you can sort this by something other (for example the size). This could look like this:

This works fine but is a very expensive operation. In the last article, we learned about Indexes. We can use them here too, to sort our output. This is especially important if we have big databases with millions of objects.

Where clause sorting

--

--

Tomic Riedel

Sharing the process of building a portfolio of apps to make people more productive.