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: can't deselect '_id' #1331

Closed
klimashkin opened this issue Feb 4, 2013 · 1 comment
Closed

Populate: can't deselect '_id' #1331

klimashkin opened this issue Feb 4, 2013 · 1 comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.

Comments

@klimashkin
Copy link

Hello!
When I'm trying to deselect '_id' field in populate (when it is array of refs), then I always get empty array.

new mongoose.Schema(
        {
            geo: {type: [Number], index: '2d'}, 
            photos: [
                { type: Schema.Types.ObjectId, ref: 'Photo' }
            ]
        },
        {
            strict: true
        }
    )
SomeCollection.find({geo: { "$within": {"$box": box} }}).populate('photos', {_id: 0}).select('-_id photos').exec(function (err, docs) {
console.dir(docs); // get here: [ { photos: [] }, { photos: [] }, { photos: [] } ]
});

If I don't deselect '_id', than all is ok: photos array for each doc is not empty

@aheckmann
Copy link
Collaborator

Thanks for the detailed report. I'm looking into it now.

On Mon, Feb 4, 2013 at 8:27 AM, klimashkin notifications@github.com wrote:

Hello!
When I'm trying to deselect '_id' field in populate (when it is array of
refs), then I always get empty array.

new mongoose.Schema(
{
geo: {type: [Number], index: '2d'},
photos: [
{ type: Schema.Types.ObjectId, ref: 'Photo' }
]
},
{
strict: true
}
)

SomeCollection.find({geo: { "$within": {"$box": box} }}).populate('photos', {_id: 0}).select('-_id photos').exec(function (err, docs) {console.dir(docs); // get here: [ { photos: [] }, { photos: [] }, { photos: [] } ]});

If I don't deselect '_id', than all is ok: photos arra fo each doc is not
empty


Reply to this email directly or view it on GitHubhttps://github.com//issues/1331.

Aaron
@aaronheckmann https://twitter.com/#!/aaronheckmann

aheckmann added a commit that referenced this issue Feb 11, 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

2 participants