I am having an issue with ordering using @react-native-firebase/database. The database looks like this below:
users: {
user_id: {
rooms: {
room_id_1: {
name: "Tom"
meta: {
lastMessage: 1579702466378
unreadCount: 0
}
},
room_id_2: {
name: "Jerry"
meta: {
lastMessage: 1579702467000
unreadCount: 5
}
}
}
}
}
Here is my query. I am expecting the results to be ordered by the 'unreadCount' key:
import firebaseDB from '@react-native-firebase/database';
firebaseDB().ref(`Users/user_id/rooms`)
.orderByChild(`/meta/unreadCount`)
.on('value', (dataSnapshot) => {
dataSnapshot.forEach((child) => {
console.log('child.key', child.key)
});
});
But looks like orderByChild order isn't being respected. The response is always:
room_id_1
room_id_2
what can be the issue here?