I've the below JSON structure for my application.
root
|
+-- groups
| |
| +-- $gid
| |
| +-- uids : [$uid1, $uid2,....,$uidN]
|
|
+-- users
|
+-- $uid
|
+-- name: "<name>",
status: "<status>",
avatar: "<url>"
How to find the gid that matches specified uids?
The method I was trying concatenated all the uids together with underscores in between.
String mGroupId = mGroupRef.push().getKey();
mGroupRef.child(mGroupId).setValue(new GroupModel(user1.getUid(), user2.getUid()));
class GroupModel {
private static final String SEPARATOR = "_";
private String uids;
public GroupModel(String uid, String uid1) {
uids = uid + SEPARATOR + uid1;
}
}
Apparently, this is not a good work.
Because, the question makes it very harder to find the gid since the order of the uids are undefined.
Any notion or a help would be highly appreciated.