I'll explain my question using USER -> TASK (1-user-can-have-many-tasks) as an example.
In realm, I can define the USER ENTITY, which includes in it a list of associated tasks.
However, when querying all users, I also want to read as part of user list, a set of attributes for each user that are summaries of an equivalent attributes on the tasks for this user.
For example, I want to read all users, and for each user, report 'Outstanding' if any of the linked tasks are outstanding. report 'Has Attachment' for a user, if ANY of the tasks for that user have attachments.
In plain SQL with SQLLite, I can achieve this effect using groupby constructs and deriving columns in my resultset that are summaries of real columns.
How can I accomplish the same in Realm. Any help is appreciated.
Example Entity:
User
{
String userId
String name
List<Task> tasks
**--> oustanding** (need to derive if any of the tasks in the task list is outstanding)
**--> hasAttachments** (if any of the tasks in the task list has
attachments)
}
Task
{
String taskId
boolean outstanding
boolean hasAttachments
}
Note: outstanding and hasAttachments on the User entity are not defined fields necessary. I just need to derive them at runtime, in query or as dynamic fields, if there is such a thing