TypeError: Seems like the schema generic is missing - did you forget to add it to your DB type?
How can I solve the following generic error relating to the
db.query.users
in my code below?
I'm trying to create an adapter that accepts a generic schema to instantiate a PostgresJsDatabase
instance, or colloquially db
.
I've created the schema that is needed for this adapter, but how can I satisfy typescript when running db.query.user.findFirst()
?
3 Replies
You are using the schema parameter passed to the
postgresAdapter
function. That parameter is typed as any.
Are you planning to use this function to pass it different schemas? What is the purpose of passing the schama as a parameter?Yeah I was looking to allow users of this function to pass in their drizzle schema that should look a certain way for me to query. But I also created the same schema myself as a fallback.
On a high level, I'm trying to create an adapter to update a user's database. But I think defining the essential elements of the schema myself may suffice instead of allowing users to pass it in.
Anyways, I think it's okay to ignore this question if defining the generic of a schema is bit complicated. Thank you
I'm not sure, but if in this line you delete the default type parameter it might work: