Firebase Multilevel Child Query Android
up vote
0
down vote
favorite
How can i get All chats where Users contains a specific Uid
Query sItemQuery = mDatabase.getReference().child("chats").limitToLast(200);
FirebaseRecyclerOptions<ChatMetaData> options =
new FirebaseRecyclerOptions.Builder<ChatMetaData>()
.setQuery(sItemQuery, ChatMetaData.class)
.setLifecycleOwner(this)
.build();
android firebase firebase-realtime-database firebaseui
add a comment |
up vote
0
down vote
favorite
How can i get All chats where Users contains a specific Uid
Query sItemQuery = mDatabase.getReference().child("chats").limitToLast(200);
FirebaseRecyclerOptions<ChatMetaData> options =
new FirebaseRecyclerOptions.Builder<ChatMetaData>()
.setQuery(sItemQuery, ChatMetaData.class)
.setLifecycleOwner(this)
.build();
android firebase firebase-realtime-database firebaseui
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How can i get All chats where Users contains a specific Uid
Query sItemQuery = mDatabase.getReference().child("chats").limitToLast(200);
FirebaseRecyclerOptions<ChatMetaData> options =
new FirebaseRecyclerOptions.Builder<ChatMetaData>()
.setQuery(sItemQuery, ChatMetaData.class)
.setLifecycleOwner(this)
.build();
android firebase firebase-realtime-database firebaseui
How can i get All chats where Users contains a specific Uid
Query sItemQuery = mDatabase.getReference().child("chats").limitToLast(200);
FirebaseRecyclerOptions<ChatMetaData> options =
new FirebaseRecyclerOptions.Builder<ChatMetaData>()
.setQuery(sItemQuery, ChatMetaData.class)
.setLifecycleOwner(this)
.build();
android firebase firebase-realtime-database firebaseui
android firebase firebase-realtime-database firebaseui
edited Nov 10 at 15:11
Frank van Puffelen
218k25361386
218k25361386
asked Nov 10 at 14:53
Wycliffe Kipkogei
2115
2115
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
You can't query across multiple levels like that. See Firebase Query Double Nested
So while your current data structure makes it easy to find the current users in a chat, it doesn't make it easy to find the current chats for a user.
For that you'll need to add an additional data structure. Something like:
user_chats: {
uid1: {
chatid1: true,
chatid2: true
}
uid2: {
chatid2: true,
chatid3: true
}
}
With this additional structure, you can easily find the chats for the current user by reading /user_chats/$uid
.
Also see:
- Firebase query if child of child contains a value
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
You can't query across multiple levels like that. See Firebase Query Double Nested
So while your current data structure makes it easy to find the current users in a chat, it doesn't make it easy to find the current chats for a user.
For that you'll need to add an additional data structure. Something like:
user_chats: {
uid1: {
chatid1: true,
chatid2: true
}
uid2: {
chatid2: true,
chatid3: true
}
}
With this additional structure, you can easily find the chats for the current user by reading /user_chats/$uid
.
Also see:
- Firebase query if child of child contains a value
add a comment |
up vote
2
down vote
You can't query across multiple levels like that. See Firebase Query Double Nested
So while your current data structure makes it easy to find the current users in a chat, it doesn't make it easy to find the current chats for a user.
For that you'll need to add an additional data structure. Something like:
user_chats: {
uid1: {
chatid1: true,
chatid2: true
}
uid2: {
chatid2: true,
chatid3: true
}
}
With this additional structure, you can easily find the chats for the current user by reading /user_chats/$uid
.
Also see:
- Firebase query if child of child contains a value
add a comment |
up vote
2
down vote
up vote
2
down vote
You can't query across multiple levels like that. See Firebase Query Double Nested
So while your current data structure makes it easy to find the current users in a chat, it doesn't make it easy to find the current chats for a user.
For that you'll need to add an additional data structure. Something like:
user_chats: {
uid1: {
chatid1: true,
chatid2: true
}
uid2: {
chatid2: true,
chatid3: true
}
}
With this additional structure, you can easily find the chats for the current user by reading /user_chats/$uid
.
Also see:
- Firebase query if child of child contains a value
You can't query across multiple levels like that. See Firebase Query Double Nested
So while your current data structure makes it easy to find the current users in a chat, it doesn't make it easy to find the current chats for a user.
For that you'll need to add an additional data structure. Something like:
user_chats: {
uid1: {
chatid1: true,
chatid2: true
}
uid2: {
chatid2: true,
chatid3: true
}
}
With this additional structure, you can easily find the chats for the current user by reading /user_chats/$uid
.
Also see:
- Firebase query if child of child contains a value
answered Nov 10 at 15:11
Frank van Puffelen
218k25361386
218k25361386
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240131%2ffirebase-multilevel-child-query-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown