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
Mongo, populate nested field only from collection #9078
Comments
Alright so going to break this down in steps: Regarding the closed issue, it was done so because it was attempting to do something we don't support (and had extremely poor formatting, which our rules are quite clear about and you did very well on in this issue)
The first one is a limitation of our population and how we handle relations, though this issue says components it also applies to certain relations. So duplicate of: #7360
Functions as intended
The population array only works on relational fields, so if you had some other relations on the user model, say users had a "comments" and "likes" relations (don't care which type) and you only wanted to populate the "likes"; Your population array would look like: Also in your case I'm guessing you forgot to change the default controller from our docs example (swap out the restaurant for the actual model name) At the moment we don't support dynamic population of fields themselves, only relational ones. We do plan to make a change I believe in Q3 which will make default population as none, and let users pick the fields (not just relational) they want to show. Marking this as closed, as aside from the duplicate issue I linked, it's working as intended. If you need more advanced population you will have to build a custom query: https://strapi.io/documentation/developer-docs/latest/concepts/queries.html#mongoose |
This issue has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/how-to-populate-component-that-comes-from-a-deep-nested-relation/3018/8 |
Hi @derrickmehaffy, I have tried your solution above and it worked perfectly. The only issue then is that all the repeatable components get deleted from the object. Is there a solution to this maybe? |
This issue has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/populate-deleted-components-and-repeatable-components/7459/1 |
Related issue, no answer,
@lauriejim why u did close it?
Model
Original query
Query 1
Actual result
Query 2
Actual result
Query 3
Actual result
Expected result
The text was updated successfully, but these errors were encountered: