0

I came across this problem, and can't figure it out. I have a node of users where I store all users

{
  users: {
    uid: {
      displayName: "stringOfSomeKind"
    }
    uid2: {
      displayName: "moreStrings"
    }
    uid3: {
      displayName: "evenMoreStrings"
    }
    ...
  }
}

And then I have a node of events, and inside of the events node I have all users assigned to that event

{
  event_name: {
    asigned_users:"uid","uid2"
  }
}

So the problem comes when the event admin wants to assign new users (from the users node) to the event, and I want to get only the users that are not already in the event (uid3 in this case). How can I do that? there is some sort of query I can run? I'm kinda new to no-relational databases so any advise would help

KENdi
  • 7,576
  • 2
  • 16
  • 31

1 Answers1

0

This asigned_users:"uid","uid2" is not valid JSON. And unfortunately the answer depends on what JSON you actually use there.

Most likely you're using an array, which is the wrong structure for this type of data. To model a set in Firebase, you'd do: asigned_users: { uid1: true, uid2: true }.

Also see my more elaborated answer from yesterday and this older, somewhat related answer here.

gprathour
  • 14,813
  • 5
  • 66
  • 90
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807