Replies: 1 comment
-
I think there is a join field for that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone,
been trying out Payload CMS for the last few days, looking good so far. However, I'm not sure how to approach this requirement I have. Disclaimer: the issue might just be that I'm more used to relational DBs.
Let's say we have 3 models:
The requirement: whenever I query a
User
document (whether I query by ID or the entire collection), I would also like to include anorders
property, which is an array of references to the orders that the queriedUser
is part of.Possible solutions that come to mind right now:
afterRead
in theUser
config - causes an infinite loop when querying theOrder
collection unless you usedepth: 0
inpayload.find()
orders
property to User and manually updating it whenever theuser_id
property changes on anyOrder
documentAm I missing an obvious solution here?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions