0

I need to list all messages where playerExcluded != firebase.auth().currentUser.uid for each user.

roomId
  |__ messageId
         |__ author: string;
         |__ message: string;
         |__ playerExcluded: string;

I'm doing that for now with a Cloud Function but I don't think this is a good practice since messages need to be update when there is a new message (=often): this is very costly (a lot of calls to cloud function).

Is there a good way to do that ?

PS/Irrelevant: Is it possible to restrict database query on only one type of query ? Sample example:

passwords
    |__ roomId: passwordValue

I need to check if the password inputted by the user is right. No problem doing the query doing that. But given that firebase rules with write/read is true OR false, I guess answer is no, can some one confirm it ?

Emeric
  • 6,315
  • 2
  • 41
  • 54
  • Firebase does not support `<>` queries. See https://stackoverflow.com/questions/39195191/firebase-query-to-exclude-data-based-on-a-condition/39195551#39195551 – Frank van Puffelen Oct 25 '18 at 09:15
  • For your second question (please limit yourself to one question per post in the future), you might want to have a look at the section on [query based rules](https://firebase.google.com/docs/database/security/securing-data#query-based_rules) in the Firebase documentation. With those you're essentially validating that the query used, is allowed according to your use-case. – Frank van Puffelen Oct 25 '18 at 09:16
  • I already saw your first link and knew about this alternative but I found that not really clean to structure my db like that. Is there any update planned to let user query with <> ? Your second link will be usefull. Thank you for your answers Frank ! – Emeric Oct 25 '18 at 09:21

0 Answers0