Hi, I’m currently developing a chat app. My data are stored in mongodb and I want to use Flexible Sync to selectively sync chats data to local. My code is something like below
class $Chat {
@PrimaryKey()
@MapTo('_id')
ObjectId? id;
...
String? channel;
late List<$Media> medias;
}
class $Media {
@PrimaryKey()
@MapTo('_id')
ObjectId? id;
...
}
realm.subscriptions.update((mutableSubscriptions) {
mutableSubscriptions.add(realm.query<Chat>(r' channel = 1 '));
});
As you can see above there is a relationship between chat and media. What I want is when chats are synced I also want each media (of synced chats only) to be synced as well.
- Is there a way to automatically sync media along with the chat?
- Or do I need to manually add a query subscription for each media? If I need to do it manually, there will many media subscriptions for each chat. Is there a subscription limitation when too many subscriptions are added?