Consider the following database structure -
tasks
task1
title: "My first task"
uid: "user1"
user-tasks
user1
task1: true
To observe changes to a specific user's tasks, you might be tempted to implement something like this -
ref.child("user-tasks").child(uid).observe(.childChanged...
But the problem is that any changes to title won't reflect in user-tasks, so childChanged event won't trigger. If you observe all tasks, then any changes to tasks for other users would cause the observer to execute needlessly. Additionally, the desired implementation would handle updates to the task by other users/devices and the update would trigger correctly.
My only thought thus far is to replace true with a timestamp that gets updated on change and would trigger the observer. Is there a better way?