tekartik/sembast.dart

Ordering by property of nested array object

acorn371 opened this issue · 2 comments

Hi,
as for issue #12 (closed) I'm having trouble about sorting by a nested object. In my specific case, nested objects are arrays of objects and I would like to order-by a field in the array object.
My sembast store contains book instances like :

{
        "id": 1,
	"title": "book title",
	"editions": [
		{
			"published": "publishing date", 
			"edition_title": "a specific edition title",
			...
		}
	],
	...
}

and I would like to sort by the "edition_title" field of the first array item.
When I call await store.find(db, finder: Finder(sortOrders: [SortOrder("editions.edition_title")])) I get all the store items apparently sorted by the id field.
Is there a specific syntax for the SortOrder i need ?

I'm using flutter 3.7.6 and I tried sembast 3.2.0+1 and 3.4.0+6.
Thanks.

I added support for accessing inner list item in sembast 3.4.1-0.
You should be able to use the following sort order:

SortOrder("editions.0.edition_title")]

Great! Thank You so much!.