Чтобы добавить к ответу Дэйва Вавры, я использую отрицательную метку времени, так как мой sort_key
нравится так
Установка
const timestamp = new Date().getTime();
const data = {
name: 'John Doe',
city: 'New York',
sort_key: timestamp * -1 // Gets the negative value of the timestamp
}
Получение
const ref = firebase.database().ref('business-images').child(id);
const query = ref.orderByChild('sort_key');
return $firebaseArray(query); // AngularFire function
Это позволяет извлекать все объекты от самых новых до самых старых. Вы также можете $indexOn
sortKey
сделать его еще быстрее