1
Good evening, I’m studying Firebase with IONIC and Angular (I’m not using Angularfire) and a question has arisen. How do I update the data saved in Firebase? To get the data I do as follows:
const config = {
apiKey: "x",
authDomain: "x",
databaseURL: "x",
projectId: "x",
storageBucket: "x",
messagingSenderId: "x"
};
firebase.initializeApp(config);
let ref = firebase.database().ref('statuspedido');//statuspedido
this.pedidos = new Array();
ref.on('value', (dataSnapshot) =>{
let items = dataSnapshot.val();
for(let dados in items){
this.pedidos.push(
new PedidoModel(
items[dados].dataEmissao,
items[dados].dataAtualizacao,
items[dados].vendedor, items[dados].frete,
items[dados].transportadora, items[dados].status)
)
}
})
My firebase structure is like this:
And I want to update the "idPedido = 1" without changing the others.
Good morning, I did as I did but instead of updating it creates new object. I need to update a specific object.
– Ronaldo Lopes
.update
will update the object if it already exists, otherwise it creates a new– Artur Trapp