Correct Client type to pass drizzle client around
Hey community,
I love drizzle but sometimes I find it quite challenging to deal with the types. I am not sure if this problem is a skill issue, thus I wanna ask you guys. Let me explain:
I am using Nest.js and I have DatabaseService file that create the drizzle client internally and exposes it. I want this service to be dynamic which means I want to be able to pass the schema to it and the type of the client should be infered automagically. But I am struggling to properly type it:
This is the relevant definitions of my types in the DatabaseService regarding the drizzle client:
The underlying schema that I am importing is:
1 Reply
I am using the client like this:
I am using this class in another service like this:
The
insert
call gives me the following type error:
Both errors are unexplainable to me and after a long time of tinkering around I am out of ideas. I have no idea what the proper type of the drizzle client is so that I can pass it to other functions
This will also give the error:
But the table definition, as seen above includes this column