Populate after find()

16 views
Skip to first unread message

Stefano Passiatore

unread,
Nov 4, 2013, 12:46:23 PM11/4/13
to mongoo...@googlegroups.com
Hi, I've these Schemas:

var InputSchema = new mongoose.Schema({
    url
: String,
    titleSource
: String,
    urls
: [{
        type
: mongoose.Schema.Types.ObjectId,
       
ref: 'Url'
   
}]
});


var UrlSchema = new mongoose.Schema({
    description
: String,
    url
: String,
    _source
: {
        type
: String,
       
ref: 'Input'
   
}
});


but
this code return undefined... and only one time (I've several instances of Urls)
    Url.find()
    .populate('
_source', 'titleSource') // only return the Persons name
    .exec(function (err, url) {
        if (err) return console.log(err);
        console.log(url._source);  
    })




Why? Thanks a lot!
Stefano
Reply all
Reply to author
Forward
0 new messages