allenA
Convex Community3y ago
3 replies
allen

Unions of literals / Enums

Has there been any consideration to supporting enums in the schema data types? I'm referring to enum in a very loose sense here -- basically type safety that a field will have a particular value.

Eg:
type MySupportedValues = 'this' | 'that';
defineSchema({
  table: definteTable({
    field: s.string(MySupportedValues),
  }),
});

Then when utilizing I will not be able to specify a value for
table.field
that isn't "this" or "that", and when i
get
a table doc, I'll have
table.field
will have a type of
MySupportedValues
.
Was this page helpful?