Query on Join Fields #9683
Replies: 2 comments 1 reply
-
The join field doesn't support querying yet. We should mention this in the docs until this can be added. For now you will need to first query the related collection and use the relationship IDs from the first query like this: `` const categoriesHavingPosts = await payload.find({
|
Beta Was this translation helpful? Give feedback.
-
Plus one for this feature! Got also this case for access control. Suppose we got students assigned to classrooms. Now we need to do a big fetch of every student before even querying the rooms.. |
Beta Was this translation helpful? Give feedback.
-
Hi, is there any way to query a collection by filtering on the join field?
For example, I have a bi-directional relationship for category and posts
How do I query for categories that the "relatedPosts" is not empty?
I tried something like
but this is giving error
Error: syntax error at or near "not"
. None of other filters like equals, in etc works.If I try with filters like "relatedPosts.doc", it is giving the error
Error: The following path cannot be queried: relatedPosts.docs
Beta Was this translation helpful? Give feedback.
All reactions