subscribeToGroup method
Subscribe the local node to a group.
This sets isSubscribed = true for the target group and
optionally unsubscribes from all other groups (since NodeRole.group
nodes can only be in one group at a time).
Implementation
Future<void> subscribeToGroup(String groupId,
{bool exclusive = false}) async {
if (exclusive) {
// Unsubscribe from all groups first
await (update(groups)).write(
const GroupsCompanion(isSubscribed: Value(false)),
);
}
await (update(groups)..where((t) => t.groupId.equals(groupId))).write(
const GroupsCompanion(isSubscribed: Value(true)),
);
}