Inability to exclude a field based on a condition #3824
Replies: 3 comments
-
Hey @GeorgeHulpoi — you'll need to set the field to Setting to |
Beta Was this translation helpful? Give feedback.
-
@jmikrut Naturally, I tried null also, but it didn't remove it from the database. Seems like you update the document in the database with the Therefore, I don't know if this is the wanted result or is a bug, but the |
Beta Was this translation helpful? Give feedback.
-
Hey @GeorgeHulpoi — well, we could certainly build a pattern to unset values that are found to be I will convert this into a feature request for MongoDB and we can monitor it there accordingly! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to reproduction
https://github.com/GeorgeHulpoi/payload-field-conditional-bug/tree/main
To Reproduce
admin.condition
based on a sibling data value.beforeChange
orafterRead
where you returnundefined
if theadmin.condition
fails.Describe the Bug
Seems like the value
undefined
will fail this condition: https://github.com/payloadcms/payload/blob/master/src/fields/hooks/beforeChange/promise.ts#L80 and because of it, I can't manage to exclude a field from the database it nor API response.Payload Version
^1.15.6
Beta Was this translation helpful? Give feedback.
All reactions