Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+10 votes

Does anyone know how to timestamp a string in firebase using React so it could be sorted a certain way?

asked in CSC490_Spring2019 by (-499 points)

1 Answer

+2 votes

If you specifically want to use a timestamp, then you could try getting the time from a Date object, then use that as the key when storing your value. When you write to Firebase it automatically sorts the items in a branch by their key.

Also, if you have children in Firebase that themselves have multiple children, you can use OrderByChild() to order what you read by a specific child. The link below is to some documentation that has the orderByChild() method listed.

https://firebase.google.com/docs/reference/js/firebase.database.Reference#orderbychild

answered by (1 point)
+1

Thanks, I will try to do that!

+1

Thanks, Imma try it out!

...