allenA
Convex Community3y ago
5 replies
allen

Query optional field on schema

I am looking to query an optional field with
.eq('fieldName', undefined)
, however, I am getting the error: [Error: Uncaught Error: undefined is not a valid Convex value. To learn about Convex's supported types, see https://docs.convex.dev/using/types.

The provided docs say to use
null
but that then breaks generated types from optional fields, as the available options are
number | undefined
.

I could refactor this into a union of a number or a null value, but figured I'd ask first as it seems like it should be possible to query an optional field directly.
Was this page helpful?