Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate a populated field #939

Closed
vartana opened this issue May 28, 2012 · 1 comment
Closed

Populate a populated field #939

vartana opened this issue May 28, 2012 · 1 comment

Comments

@vartana
Copy link

vartana commented May 28, 2012

My document has a document that has a document. I wanted to find out how i can populate the inner document as well. I have tried this but it is not populating my innter document.

    Document.find({})
    .populate('owner')
    .populate('owner.company')
    .run(function(err,docs){
    if(err){
        req.flash('error', 'An error has occured. Please contact administrators.')
    }
    console.log(docs);
    res.render('dashboard/index', { title: 'Dashboard', menu: 'Dashboard', docs: docs});
var mongoose = require("mongoose"),
    Schema   = mongoose.Schema,
    ObjectId = Schema.ObjectId,
    DocumentObjectId = mongoose.Types.ObjectId;

var Document = new Schema({
    filepath: {type: String, required: true},
    createdBy: {type: String, required: true},
    created: {type: Date, default: Date.now},
    owner: {type: ObjectId, ref: 'owner'}
});

var Owner = new Schema({
    fullname: {type: String, required: true},
    company: {type: ObjectId, ref: 'company'}
});

var Company = new Schema({
    name: {type: String, required: true},
});
@aheckmann
Copy link
Collaborator

this is being tracked in #601. closing this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants