firebasereact-nativereact-native-firebase

react-native-firebase orderBy query not working


I try to sort data then get them from the database using the following query:

import firestore from '@react-native-firebase/firestore'
   // not working
 const query = await firestore().collection('col').orderBy('createdAt', 'desc').where('age', ==, '123').get()

  // this is working but not sorted
  const query = await firestore().collection('col').where('age', ==, '123').get()

I also find react-native-firebase/firestore (v12.9.2) does not support startAt. Feel something not right as According to the documentation, these features are all supported in React Native


Solution

  • need to setup index in Firebase before query.