I have problems reading this collection with mongoose and Node.js:
I have one JSON inside my Collection and i try to read this with this code:
materias.find().exec(function(err1,materias){
if(err1){console.log(err1); return next();}
for(x=0;x<materias.length;x++){
//console.log(materias[x].Nombre);
//var arreglo=materias[x].Horario[0].Dia; // TRY ONE
var arreglo=JSON.parse(materias[x].Horario[0]); // TRY TWO
console.log(arreglo[0]);
}
//RESPONSE TRY ONE
console.log(arreglo) UNDEFINED
//RESPONSE TRY TWO
undefined [
//if I use JSON.stringify the response is {[object][object]...
Suggestions...
materias is not an array, given your example.
--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
var arreglo = materias[x].Horario[0]; console.log(arreglo); //Response: [[
console.log(materias[x].Nombre)// Response: Tópicos Selectos de Programación
console.log(materias[x].Horario) // Response: [object Object],[object Object],[object Object],[object Object],
console.log(materias[x].Horario[0].Dia); // Response: Undefined
console.log(materias[x].Horario.Dia[0]) // Response: Cannot read property '0' of undefined