In Javascript, calling push on a firebase ref would generate a random ID. Then you can populate the stuff below.
However, I can't find push in Swift. Do I have to generate random IDs myself?
I think you're looking for childByAutoId()
:
childByAutoId
generates a new child location using a unique key and returns a FIRDatabaseReference to it. This is useful when the children of a Firebase Database location represent a list of items.The unique key generated by childByAutoId: is prefixed with a client-generated timestamp so that the resulting list will be chronologically-sorted.
Declaration
func childByAutoId() -> FIRDatabaseReference
Also see: https://firebase.google.com/docs/database/ios/read-and-write#update_specific_fields
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With