0

Assume my data looks something like this :

{
  "key_data" : {
    "1qwqwqwqwq" : {
      "map_id" : "9010",      
    },
    "1212wdwdw" : {
      "map_id" : "098",      
    },
    "1212dfefe" : {
      "map_id" : "5612",      
    },
    "1212eerer" : {
      "map_id" : "987",      
    }            
  }
}

In Firebase iOS Swift Library how do I get all key_data where map_id in ['9010','098']?

Currently I am running this piece of code in a loop and appending the result into an array:

// for map_id in map_ids---
ref.queryOrderedByChild("map_id").queryEqualToValue(map_id)
                                 .observeEventType(.Value) { snapshot in
                                     //append into array
                                 }
Marcus Rossel
  • 3,196
  • 1
  • 26
  • 41
Kiran Ruth R
  • 902
  • 1
  • 11
  • 28
  • There is no built-in `IN` operation in Firebase. This has been asked before, so I'll find a duplicate. – Frank van Puffelen Nov 09 '15 at 15:05
  • 1
    Possible duplicate of [firebase equivalent to sql where in ()](http://stackoverflow.com/questions/29560088/firebase-equivalent-to-sql-where-in) – Frank van Puffelen Nov 09 '15 at 15:06
  • Depending on the size of your dataset, (a few thousand) we have found an easy option is to read in the key_data node into Snapshot and then into an array. Filter using NSPredicate. Another option is to use ChildAdded event which auto-iterates over all of the children and just load the items of interest into an array as they are read in. It all depends on your dataset size. – Jay Nov 09 '15 at 20:07

0 Answers0