How can I return only user.profile.rating.content without getting the full profile and rating objects? #13289
-
I’m on Payload v3.49 (MongoDB) and trying to fetch only specific deeply nested fields without over-fetching.
📄 Query I’m running
✅ What I expect Only the content field from the rating, nested inside profile:
❌ What I actually get (simplified)
🤔 Questions
|
Beta Was this translation helpful? Give feedback.
Answered by
matthijs166
Jul 28, 2025
Replies: 1 comment 1 reply
-
From a quick look, I don't think you can make the rating relationship inside profile populate recursively in the way you're expecting. Instead, you want to:
What I think happens now:
Try something like this: const res = await payload.find({
collection: 'users',
where: { email: { equals: '[email protected]' } },
select: { profile: true },
populate: {
profile: {
rating: true
},
rating: {
content: true
},
},
depth: 3,
}); Are you using typescript? Think that this normally would give a type error. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
shoodoow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From a quick look, I don't think you can make the rating relationship inside profile populate recursively in the way you're expecting.
Instead, you want to:
What I think happens now:
Try something like this: