-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Query by subcollection #1009
Comments
In Cloud Datastore it's possible to get up to 1,000 entities with an array of keys.
Is something similar on the roadmap in Firestore? I think this could solve many of the relational challenges like the one referenced above. |
Don't think subcollection query would satisfied this case Instead I think you need //team doc
{
"members" : {
"userID1" : true,
"userID2" : true,
"userID3" : true,
"userID4" : true,
}
} var teamQuery = db.Collection("teams").WhereEqualTo("members.{userID}",true); |
@Thaina, this is the solution I am currently using. However, this approach is not very scalable. A team couød potentially have thousands of members. |
i think same FR already exist |
@sondresorbye0111 Then you need the opposite, storing teamID in user doc. Given that the more possible side of relation would be the main to store the less one And if you need true scalable of both side. Maybe you need another collection, a relationship collection. Which is storing very small document, only docid : "teamID:userID"
{
"team" : "{teamID}",
"user" : "{userID}",
} And so you could query both way |
@Thaina, this is a solution, but it requires two roundtrips to the database. Therefore, I think it would actually be slower than downloading some extra other users IDs. |
Thanks for your interest! This is a duplicate of #572. As we said there, this is definitely on the road map. Right now we're working on stabilizing what we have for GA so this isn't imminent, but this is very high on our list of priorities, don't worry :-). |
I want to get all teams where the user is a member of. Currently, I am querying by a object with uid as key.
The teams can potentially have thousands of members and the user can be member of many teams. Therefore, this approach is not scalable. A better approach would be to query be a subcollection with all users.
I also could make another collection to make a relationship between the users and teams (like SQL databases). The problem with this is that a have to make another request to Firestone.
Is it a scalable solution to this?
The text was updated successfully, but these errors were encountered: