I'm trying to receive a list of posts where someone posted a comment in the last 2 days from the Firebase realtime database.
const currentTime = Date.now();
const twoDaysAgo = currentTime - (2 * 24 * 60 * 60 * 1000);
Database.ref(`posts`).orderByChild(`comments/{comment}/createdAt`).endAt(twoDaysAgo).on('child_added', snapshot => {
console.log(snapshot.val());
});
I think I'm doing something wrong in the orderByChild part because I'm receiving all the posts.
My database structure looks like this