Say I have three SQLite tables week
, day
, event
.
A week
entry can have multiple day
child entries which in turn can have multiple event
child entries.
To fetch a whole week
entity with associated kids to be displayed in a TableLayout
I would usually do the following query:
SELECT * FROM week JOIN day on week.id = day.week_id JOIN event on day.id = event.day_id WHERE week.id=foo
This would return a cursor I could easily parse.
What is the equivalent of this flow in SQLBrite?
I have to map the resulting observable of db.createQuery
to either mapToList
or mapToOne
which is kind of tricky to grasp. I tried mapping to one and then parsing the cursor in a subscriber but I got a cursor has multiple lines exception. Mapping to a list is somehow unnatural since I only expect one week
entry at the end.
What am I missing? :) Thanks!