chrisgl
unread,Aug 26, 2011, 6:29:45 AM8/26/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mongoose Node.JS ORM
Hello!
First of all! The new DBRef-Function with Populate is great! It works
very smooth.
But I found a problem, which is not described in the Examples.
I have a Schema with one Populated Field creator which resolves to the
User schema. This works fine.
There is also an Array of embedded Documents (comments) which has a
field createdby, also resolving to User schema.
The Exampleschema is below. If I try to populate the Embedded
document's ref it fails!
My Query looks like this:
Schema.findOne({titel:id}).populate('creator').populate('comments.createdby').run(function(err,
result){});
But the Callback is never called. So I get no Answer from my page!
So my Question is: How do you Populate DBRefs in Embedded Documents?
Exampleschema:
var CommentSchema = new Schema({
text: String,
date: {type: Date, "default": Date.now},
createdby: {type: ObjectId, ref:'user'}
});
var ExampleSchema = new Schema({
titel: {type: String, unique: true},
created: {type: Date, "default": Date.now},
creator: {type: ObjectId, ref:'user'},
comments: [CommentSchema]
});
Thanks in advance!