0

enter image description here

As shown in the image above, I got the exact construction. What I am trying to do right now is to compare a custom value given by me and to compare to each of the ip keys' values for either Paster or Ruzgar child. I will add a condition that if, for instance, such ip value has already been registered under Paster child for example, then return you have already been registered, else add that value with another push() function.

I am using Node.js as my app is integrated with React. Each iteration is not reasonable in my case, as I believe this data will expand to thousands, and considering each request will take some time, it will end up taking a decent amount of latency. What is the most logical way to collect all the ip values under this construction?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • This might not be especially helpful to you but Firebase isn't a good choice for these types of queries. It would be trivial to search for the values in a table in a SQL database or even certain non-relational databases like MongoDb. But in Firebase you would need to get both Paster and Ruzgar and check the data in your application or iterate over the the documents until you find a match. – Geraint Anderson Mar 20 '21 at 14:28
  • I get your point, and you are actually right. As the iterating is really pretty much deprecated in my opinion, I might consider switching to MongoDB actually if a reasonable is not going to appear soon. Thank you for the feedback! – Vusal Ismayilov Mar 20 '21 at 14:33
  • Firebase database queries work over a flat list of nodes, where you can then order and filter on a value that exists at a fixed path under each direct child node of the location you query. So you can search the child nodes of `Paster` for a specific `ip` or the child nodes of `Ruzgar` for a specific `ip`, but you cannot search across the entire database for a specific `ip`. Also see https://stackoverflow.com/questions/27207059/firebase-query-double-nested – Frank van Puffelen Mar 20 '21 at 14:56
  • @FrankvanPuffelen I have already actually checked the solution you have provided, however, I have to iterate over every single child key-value in order to compare each of them individually, which actually not going to be acceptable as I am going to work with 10s of thousands of different child branches. I was just interested whether Firebase was actually capable of getting all the different child values with the same key ID to a list or not. I guess without iterating each of them does not seem to possible, right? – Vusal Ismayilov Mar 20 '21 at 15:38
  • If it was possible to perform the query you are asking for, it would also have been an answer for the question I linked. You (and the OP in the linked question) are trying to order/filter on a value that is not at a fixed location under each direct child, which is not possible. – Frank van Puffelen Mar 20 '21 at 15:44

0 Answers0