工作正常 firebase.firestore()。collection('Location')。orderBy(“ syncedAt”,“ desc”)。get()
它也可以正常工作 firebase.firestore()。collection('Location')。where('email','==',email).get()
但同时使用orderBy和不起作用的地方
getUserPastInformation = async (email) => {
this.Location = firebase.firestore().collection('Location').orderBy("syncedAt", "desc").where('email', '==', email)
await this.Location.limit(10).get().then(res => {
let locationHistory = []
this.setState({ lastData: res._docs[res._docs.length - 1]._data.syncedAt })
res.docs.forEach(element => {
locationHistory.push(element.data())
});
const data = locationHistory.sort((a, b) => Moment(b.syncedAt).unix() - Moment(a.syncedAt).unix());
if (res.docs.length > 0) {
this.setState({
locationHistory: data,
loader: false
})
}
}).catch(err => {
console.log('err----->>>', err)
});
}