How to associate parent to children so children has the id of parent? #1679
-
Hi! I'm trying to create a relation between a Task and a Step. I got the part where the Task has a relationTo Step, but i cannot find how to give the step collection the id of the parent(the task associated) I've tried using collection hooks, but the object is partial and i only got the id of the step, not the actual object : I want to know it the collection hooks is the way to go and how i would access the step object from the hook in the task collection or if there is a better way to do this. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You will need to perform a // Note: there will be a more eloquent way to do this, since you will likely want to loop and get all steps?
const fullDoc = await payload.findByID({ collection: 'steps', id: step[0].value }); |
Beta Was this translation helpful? Give feedback.
You will need to perform a
payload.findByID
(see here) operation to look up the entire step document.