How to use wildcard in Firebase?

This is my Firebase database:

ft-records userX@gmail _com 2013-01-01 00:00:00 GMT addedByUser: " userX@gmail.com " notes: "Boooo" time: "2013-01-01 00:00:00 GMT" 2013-01-02 10:00:00 GMT addedByUser: " userX@gmail.com " notes: "Yeaah" time: "2013-01-02 10:00:00 GMT" userY@gmail _com 2013-01-01 03:00:00 GMT addedByUser: " userY@gmail.com " notes: "Ok" time: "2013-01-01 03:00:00 GMT" 

I can request this data like this for an authenticated user, for example. userX @gmail_com

 let userRecords = self.ref.child(self.user.email.replacingOccurrences(of: ".", with: "_", options: .literal, range: nil)) userRecords.queryOrdered(byChild: "time").queryStarting(atValue: startOfDayDateString).queryEnding(atValue:endOfDayDateString).observe(FIRDataEventType.value, with: { snapshot in ... } ) 

But if I want to request all notes from all users for a certain date, how can I achieve this?

I needed to somehow create a template for reading all the children from the root, and then request the time of each child. But I'm not sure how to do this.

Can I do something like this?

 let ref = FIRDatabase.database().reference(withPath: "ft-records/*") 
+5
source share
1 answer

You will use the Firebase database queries for this.

 let ref = FIRDatabase.database().reference(withPath: "ft-records") let query =ref.queryOrdered(byChild: "time").queryStarting(atValue: "2013-01-02 00:00:00 GMT").queryEnding(atValue: "2013-01-02 23:59:59 GMT") 

For more information, see the Firebase documentation on data filtering and the Firebase codelab for iOS .

0
source

Source: https://habr.com/ru/post/1265685/


All Articles