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

population regression in 3.6.5 #1441

Closed
aheckmann opened this issue Apr 18, 2013 · 0 comments
Closed

population regression in 3.6.5 #1441

aheckmann opened this issue Apr 18, 2013 · 0 comments
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.

Comments

@aheckmann
Copy link
Collaborator

var CommentSchema = new Schema({
 creatorId : {
           type : ObjectId,
                ref : 'User',
   },
      body : {
                type : String
   },
});
var Comment = db.model('Comment', CommentSchema);


//User
var UserSchema = new Schema({
       name : {
                type : String
   }
});

var User = db.model('User', UserSchema);


var user = new User({ name: 'Jack'});
user.save( function( error, user){
 var comment = new Comment({
             creatorId: user._id,
            body: 'Comment to you'
  });
     comment.save( function(error, comment){
         var comment2 = new Comment({
                    creatorId: user._id,
                    body: 'Comment to you'
          });
             comment2.save( function(error, comment2){

                        Comment.find()
                  .select( 'creatorId')
                  .select('-_id')//The condition to reproduce
                    .populate('creatorId')
                  .exec( function( error, comments){
                              console.log( comments[0].creatorId.name);//undefined
                        });

                });
     });
})

see https://groups.google.com/d/msg/mongoose-orm/Hvz2sixp6q0/2pVZOY3b2pgJ

aheckmann added a commit that referenced this issue Apr 18, 2013
aheckmann added a commit that referenced this issue Apr 19, 2013
aheckmann added a commit that referenced this issue Apr 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

No branches or pull requests

1 participant