I have a number field which is optional, and if set and unset gets a
nullvalue. If I use:
{
or: [
{
numberField: {
exists: false,
},
},
{
numberField: {
equals: null,
},
},
],
}it does not match the field.
Is this a bug or is there another way to check if a field specifically has a
nullvalue? My assumption was that
nullwould still match the
exists: falsequery
hi
@93699784942034944- I replicated your query and it worked correctly for me. Exists>false returned the same docs as equals>null.
To get the docs that have
numberField: nulland not the ones where it is undefined, I used:
where: {
and: [
{
numberField: {
equals: null,
},
},
{
numberField: {
exists: true,
},
}
]
},thanks for that; I can confirm it does indeed work when doing this in payload, but in a REST query, it does not work
I assume this is because
nullis not a valid query parameter value
This behaviour seems strange though, I would expect that a field that has it's values removed, would have the same
undefinedvalue as if the field had never had the value set in the first place
Star
Discord
online
Get dedicated engineering support directly from the Payload team.