FrankF
Convex Community14mo ago
3 replies
Frank

Is there a way to infer "union of column name literals" from a table schema?

Hi! When implementing a query that accepts sortBy as an arg, I'm specifying it to be a string.

  args: {
    sortBy: v.optional(v.string()),
    sortOrder: v.optional(v.union(v.literal("asc"), v.literal("desc"))),
  },


I want to enforce sortBy here to be one of the column names of a table, but ideally don't want to hardcode the column name literals here.

I wonder Is there a way to infer "union of column name literals" from a table schema?

Appreciate any thoughts on this!
Was this page helpful?