0
Good morning, I am studying IONIC with Firebase and created a simple list where I want it to be sorted by update date. In the image we can see that the date is the same as it came from Firebase.
I tried to do it this way:
pedidos:any
constructor(){
// Initialize Firebase
const config = {
apiKey: "c",
authDomain: "c",
databaseURL: "c",
projectId: "c",
storageBucket: "c.c.c",
messagingSenderId: "c"
};
firebase.initializeApp(config);
this.pedidos = new Array();
let ref = firebase.database().ref('statuspedido').orderByChild('dataAtualizacao');//statuspedido
ref.on('value', (dataSnapshot) =>{
let items = dataSnapshot.val();
for(let dados in items){
this.pedidos.push(
new PedidoModel(
items[dados].idPedido,
items[dados].dataEmissao,
items[dados].dataAtualizacao,
items[dados].vendedor,
items[dados].frete,
items[dados].transportadora,
items[dados].status)
)
}
})
}
and at firebase:
related: https://answall.com/questions/235413/order-do-mais-recente-para-o-mais-antigo-no-firebase
– novic
reading: https://firebase.google.com/docs/firestore/query-data/order-limit-data?hl=pt-br
– novic