Seeing array elements in mongoose js
so I have this schema for a thread (it's pretty much a chat room:)
var threadSchema = mongoose.Schema({
messages: [{
message:String,
type:String
}],
point_id:String
});
I compile into a model as shown:
var Thread = mongoose.model('Thread',threadSchema);
My problem is that when I access the message element in the thread object
like this:
console.log(thread_instance.messages);
It prints out '[object Object]'. It does this even if I parse it in the
browser; it's literally returning that string '[object Object]'. How do I
access the array of elements within messages properly so that it returns
the right objects? Thanks!
No comments:
Post a Comment