Group Group Group Group Group Group Group Group Group

Firebase - Read from date child?


#1

Hi,

I want to access data from a child that is written with a date stamp.
This is how I´m writing to Firebase:

//Get user ID
let user = Auth.auth().currentUser!.uid

//Get date

let date = Date()
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date)
let minute = calendar.component(.minute, from: date)
let second = calendar.component(.second, from: date)
let year = calendar.component(.year, from: date)
let month = calendar.component(.month, from: date)
let day = calendar.component(.day, from: date)
let dateAndTime = ("(day)-(month)-(year) at: (hour):(minute):(second)")

//Write to Firebase

let userData = ["Order" : dataArray] as [String : Any]
        self.ref?.child("users").child(user).child("Orders").child(dateAndTime).updateChildValues(userData, withCompletionBlock: { (error, ref) in
            if error != nil{
                print(error!)
                return
            }
        })

I want to read data from the dateAndTime child and post it to a tableView. How can I access the data?

Hope someone can help me out.


#3