I am attempting to sort some news posts within my react-native application using orderBy() from newest to oldest. They are saved in Firestore. Whenever I use orderBy("date", "asc") or even orderBy("date", "desc") for that matter, it fails to retrieve any results.
My code for adding posts to Firestore looks like the following:
I'm using the withFirestore HOC and calling orderBy() without the second parameter works without issue, but I'm looking to get my posts from newest to oldest and sorted by this date parameter.
I am attempting to sort some news posts within my
react-native
application usingorderBy()
from newest to oldest. They are saved in Firestore. Whenever I useorderBy("date", "asc")
or evenorderBy("date", "desc")
for that matter, it fails to retrieve any results.My code for adding posts to Firestore looks like the following:
this.props.firestore.add({ collection : "posts" }, { ...details, date : firestore.Timestamp.fromDate(new Date()) });
I'm using the
withFirestore
HOC and callingorderBy()
without the second parameter works without issue, but I'm looking to get my posts from newest to oldest and sorted by this date parameter.My dependencies are as follows:
"react": "16.9.0"
"react-native": "0.61.5"
"react-native-firebase": "^5.5.6"
"react-redux": "^7.1.1"
"react-redux-firebase": "^3.0.0-beta.2"
"redux": "^4.0.4"
"redux-firestore": "^0.9.0"
I'm testing this out on an Android Emulator.