Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Swift equivalent of push()

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?

like image 241
Script Kitty Avatar asked Mar 17 '17 06:03

Script Kitty


1 Answers

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

like image 102
AL. Avatar answered Sep 28 '22 05:09

AL.