I have a function that stores a JSON object as a parameter and breaks it down into two new objects:
function insertDB(result){
var identification = "cadena";
for (var i = 0; i <= result.length; i++) {
while(result[i].Identificacion != identification ){
db.ref('Estudiantes/'+ result[i].people_code_id).set({
nombre: result[i].Nombres,
identificacion: result[i].Identificacion,
programa : result[i].ProgramaMateria,
direccion : result[i].DIRECCION,
ciudad: result[i].CIUDAD,
departamento: result[i].DEPARTAMENTO,
telFijo: result[i].TelFijo,
telMovil: result[i].TelMovil,
peopleCode: result[i].people_code_id,
correo: result[i].EMAIL,
});
identification = result[i].Identificacion;
}
}
var CodigoMateria = 0;
for (var i = 0; i <= result.length; i++) {
while(result[i].CodigoMateria != CodigoMateria){
db.ref('Materias/'+ result[i].CodigoMateria).set({
CodMateria : result[i].CodigoMateria,
Nombre: result[i].NombreMateria,
Facultad: result[i].Facultad,
Semestre: result[i].Semestre
});
CodigoMateria = result[i].CodigoMateria;
}
}
}
The problem is that it only saves the first JSON object (Students) in the BD (FIREBASE) and it does not generate the second one, I have tested the methods separately and they both send, but putting them together so that the two objects are sent does not work .