Currently I have a node called 'releases', which contains the following object:
As I do so that the same key that is generated by push of the firebase in that object is "L_E401l0yZ...." save it in a property of that object, so that it is like this:
-L_E401I0yZmGMn12L07{
fecha_creacion: "2019-3-5"
mensaje: "mensaje del primer comunicado"
titulo: "primer comunicado"
id: "L_E401I0yZmGMn12L07"
}
What I have done in the following way, but I have not had results:
crearComunicado(comunicado){
let vm = this;
let fecha_actual = new Date()
let anio = fecha_actual.getFullYear();
let mes = fecha_actual.getMonth()+ 1;
let dia = fecha_actual.getDate();
let hoy = anio + "-"+mes+"-"+dia;
var myRef = firebase.database().ref().push();
var key = myRef.key();
console.log("KEY");
console.log(key);
firebase
.database()
.ref('comunicados')
.push({
titulo: comunicado.titulo,
mensaje: comunicado.mensaje,
fecha_creacion: hoy,
id: key
})
.then(()=>{
console.log("Comunicado creado exitosamente");
vm.dialogCrear = false;
})
}