I have a field in a collection called "accounts" that has a field "attachments" that I would like to show conditionally based on what is present in another collection "licenses." Is there a way to do this? I attempted to do this using payload.find(), however "condition" only accepts a function that returns a boolean not a Promise.
Hey there! Good question. Conditional logic runs very very frequently, and it should be optimized as heavy as possible. So they explicitly do not allow asynchronous actions, and you definitely would not want to be fetching anything directly within a condition because of this. Could you populate the data from your licenses collection on your document that would be requiring the condition? You would need to replicate the shape of the license data on your accounts collection (commonly referred to as a virtual field) where the data wouldn’t actually be stored, but could be accessed in your conditional logic as usual. Does that make sense?
Yes! It totally does. Thanks for the quick response!
Star
Discord
online
Get dedicated engineering support directly from the Payload team..