Generic wrapper for drizzle-arktype functions
When using the
drizzle-arktype
functions I found myself writing the following two lines over and over again when validating my API requests:
So I wanted to abstract this away into a function that currently looks like this:
The issue I am facing now is that I get a Property 'omit' does not exist on type ...
error.
Initially I just used AnyPgTable
as the generic type so I thought that adding the column definitions might help but I was seemingly wrong.
I don't know if this is the right place to ask but I would greatly appreciate any help :)5 Replies
CC @Mario564 do we know that
createInsertSchema
will always create an object Type?
If it's inferred as Type<any> or similar that would probably be the reason object-specific methods like .omit
weren't availableThe generic type should be declared as:
You may also need to wrap the
Column
types with other types like NotNull
, HasDefault
, etc.I don't know if I am being stupid but I dont think that
PgIntegerColumn
etc. exist. Also the PgTableWithColumns
type takes a bunch of other arguments like name, dialect etc. The suggested code above did not work for me. I now tried the following. Manually providing the types like so:
Or just taking the type of a real table like so:
Neither of these worked for me
@Mario564 sorry for the ping but would you mind looking at this one more time id really appreciate itYou could try:
yeah even when filling out all the attributes it does not work. Would it not make sense to just always emit an object type? After all its a datatable it will always be an object