Skip to content

filtering by child collection #83

Answered by appy-one
ahdat81 asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, so if I understand it correctly, this is your datamodel:

{
   "groups": {
      "group1": {
          "members": {
             "member1": "user1uuid",
             "member2": "user2uuid",
             "member3": "user3uuid"
          }
      },
      "group2": {
         "members": {
            "member1": "user3uuid"
         }
      }
   }
}

And you'd want to get all groups that, say user "user3uuid" is a member of?

Option 1:

Convert your members collections to arrays:

{
   "groups": {
      "group1": {
          "members": ["user1uuid", "user2uuid", "user3uuid"]
      },
      "group2": {
         "members": ["user3uuid"]
      }
   }
}

You can then create an array index (optional):

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ahdat81
Comment options

Answer selected by ahdat81
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants