update where multiple conditions
Trying to do something like a:
UPDATE table SET values WHERE condition1 AND condition2
other ORMs will all you to pass in an object for conditions and they'll handle it under the hood, does Drizzle have something like this or do I need to do something like:
18 Replies
hmm
tried to do something like
but getting error
That seems to be a type error, you could get around that by doing:
hmm I tried that but it didn't work, might have to update in my fn interface too
Yeah, I don't know what Table is
i guess let me do a full copy and paste:
tried a few variations of the
key as keyof...
with different types without success
also tried to mess with the conditions
type a bitLooks like
NewProjectRender
and ProjectRenderTable
are just types, not actual tables
You have to import the tables from the schema, not the typesProjectRenderTable
is the pgTable definition from the schema
What is the shape of
conditions
?should be
Partial<NewProjectRender>
i'm using it to find specific rows to update
i've tried a few different types, still same error
i've also tried eq(ProjectRenderTable[key as keyof typeof ProjectRenderTable], value)
, somewhat of a different error
I think the problem is the shape of conditions. How are you defining that?
only tried to explicitly define it in the signature, so something like
ideally i want to use import
update
and invoke it with different conditions so i'm thinking it makes sense here
don't mind changing it elsewhere thoughWell, by the way you are using it it should be an object with column names for ProjectRenderTable and the value it should be equal to the value you want it to be equal to
yeah, I'm using it something like this:
which should be defined cols of ProjectRenderTable
That should work
yeah, it does, i just get the type error
even with your last snipppet above, i get have the type error:
Type 'boolean' is not assignable to type 'SQLWrapper'
actually do you mean I have to explicitly define an object with the col names i'll update?
like this?
still gives me the Type 'boolean' is not assignable to type 'SQLWrapper'
type error abovee