我尝试对数据进行排序,然后使用以下查询从数据库中获取它们:
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()
我还发现
react-native-firebase/firestore
(v12.9.2)不支持startAt
。感觉有些不对劲,根据文档,这些功能在 React Native 中都是支持的
查询前需要在 Firebase 中设置索引。