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

Advanced query: populate a document to show linked documents by replacement #381

Open
aogilvie opened this issue Dec 7, 2017 · 1 comment

Comments

@aogilvie
Copy link

aogilvie commented Dec 7, 2017

Awesome Project BTW.

sample schema for a resume app or whatever:

// People
{
    name: { type: String, required: true },
    experience: [ Company ]
}

// Company
{
    name: { type: String, required: true },
    dateStart: { type: Number, required: true },
    dateFinish: { type: Number, required: false }
}

If I search an embedded doc in our People collection its easy:

{
    "experience.company.name": {$regex : "company name"} 
}

However... if I define my People Scheme like this because Company is never unique to People:

// People
{
    name: { type: String, required: true },
    experience: [ { type: Schema.Types.ObjectId, ref: 'Company' } ]
}

How can I now search in People for matches of Company name?
Advanced search will not run populate() on my query and I right? But I need to as stated here: http://mongoosejs.com/docs/populate.html

(I am also interested in Dynamic References as new from 4.5 and how this will affect searching)

@aogilvie aogilvie changed the title Advanced query: populate a document to show embedded documents Advanced query: populate a document to show linked documents by replacement Dec 7, 2017
@aogilvie
Copy link
Author

aogilvie commented Dec 7, 2017

Updated Title for accuracy.

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

1 participant