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 : steps: [ { value: '639b487524769b06297d5b25', relationTo: 'steps' } ],
.
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!
You will need to perform a payload.findByID
(see here) operation to look up the entire step document.
// 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 });
Star
Discord
online
Get dedicated engineering support directly from the Payload team..