0

I have this code for read data from Firebase with condition, but I need multiple condition. I need one more condition for read. I don't know how to do it, I founded it isn't supported, but I need it. Can me help anyone how to do it?

ref?.queryOrdered(byChild: "project").queryEqual(toValue: "inbox").observe(.value, with: { (snapshot:FIRDataSnapshot) in
        var newTasks = [Task]()

        for sweet in snapshot.children {
            let sweetObject = Task(snapshot: sweet as! FIRDataSnapshot)
            newSweets.append(sweetObject)
        }

        self.tasks = newTasks
        self.tableView.reloadData()

    }) { (error:Error) -> Void in
        print(error.localizedDescription)
    }

Data in firebase:

data in firebase

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
user7355869
  • 53
  • 1
  • 10
  • Can you provide a sample of your database data? – Rodrigo Ehlers Jan 10 '17 at 22:46
  • I edit answer. It is in it. – user7355869 Jan 10 '17 at 22:49
  • So what exactly are you trying to achieve. Reading from the code I can see you are trying to order your `Tasks`s child nodes by their child `project`. Do you only want `Tasks` whose child node `project` equals to `"inbox"`? – Rodrigo Ehlers Jan 10 '17 at 22:53
  • @hotrod It is only one condition, but I want one more. I need more condition with read by "checked" value, but if I add one more `queryOrdered(byChild: "project").queryEqual(toValue: "inbox")` and wrote me error. – user7355869 Jan 10 '17 at 22:57

1 Answers1

4

This is not possible. You will either have to

1. filter most on the server, do the rest on the client

or

2. add a property that combines the values that you want to filter on

or

3. create a custom index programmatically

All these quotes come from this excellent answer over here at this question.

Hope this helps.

Community
  • 1
  • 1
Rodrigo Ehlers
  • 1,830
  • 11
  • 25