I have an application where new children get added to Firebase every 5 seconds or so. I have thousands of children.
On application load, I\'d like to process the ini
Added a createdAt timestamp in the database and limited the child_added with the current time and it seems working fine to me.
const onChildAdded = database()
.ref(refURL)
.limitToLast(constValues.LAST_MESSAGE_ADDED)
.orderByChild('createdAt')
.startAt(date.getTime())
.on('child_added', (snapshot) => {
parseMessage(snapshot);
});
database()
.ref(refURL)
.limitToLast(constValues.LAST_MESSAGES_LIMIT)
.once('value', (snapshot) => {
parseInitialMessages(snapshot);
setLoading(false);
});