Arrays 如何反转Firestore的数据阵列?角度6
我想将数据从新数据反转为旧数据,我在object ex:[1,2,3,4,5]中设置了idNumber 注意您可以在收款呼叫中使用orderBy 显示了如何专门使用orderBy 使用服务器对数据进行排序可以提高客户端性能Arrays 如何反转Firestore的数据阵列?角度6,arrays,typescript,google-cloud-firestore,angular6,angularfire2,Arrays,Typescript,Google Cloud Firestore,Angular6,Angularfire2,我想将数据从新数据反转为旧数据,我在object ex:[1,2,3,4,5]中设置了idNumber 注意您可以在收款呼叫中使用orderBy 显示了如何专门使用orderBy 使用服务器对数据进行排序可以提高客户端性能 listItemAds() { this.itemList = this.afs.collection<Class>('Collection'); this.itemList.snapshotChanges().subscribe
listItemAds() {
this.itemList = this.afs.collection<Class>('Collection');
this.itemList.snapshotChanges().subscribe(list => {
this.itemArray = [];
list.forEach(action => {
const data = action.payload.doc.data() as Class;
this.itemArray.push(data);
--> this.itemArray.reverse(); // I try use this.itemArray.reverse(data.idNumber) ==> error
});
});
console.log(this.itemArray);
}
this.itemList = this.afs.collection<Class>(
'Collection',
ref => ref.orderBy('idNumber', 'desc')
);
this.itemList.subscribe(list => {
console.log(list);
});