Andy Hartnett
1 min readAug 1, 2019

--

I recommend adding a date to the messages when you push them to firebase:

const message = {
username: this.username,
text: e.target.value,
date: (new Date()).getTime()
}

And then doing this to order and limit the data you get back:

const itemsRef = fire.database().ref(‘messages’).orderBy(‘date’, ‘desc’).limit(10);

--

--