Getting types for update query

Similar to $inferInsert, is there a $inferUpdate to get types while performing a db.update()
Solution:
Like Partial<typeof users.$inferInsert>
Jump to solution
7 Replies
Angelelz
Angelelz15mo ago
You can use $inferInsert for updates.
vr7bd
vr7bdOP15mo ago
Sorry for the late reply but yeah I was using it but then, if you don't have the values that are not nullable, lsp starts complaining.
Angelelz
Angelelz15mo ago
That's expected behavior. If the value is not nullable you need to provide it
vr7bd
vr7bdOP15mo ago
Yeah but when you're trying to update, it's not necessary right
Angelelz
Angelelz15mo ago
You're right, in that case I would suggest the Partial utility type.
Solution
Angelelz
Angelelz15mo ago
Like Partial<typeof users.$inferInsert>
vr7bd
vr7bdOP15mo ago
Alright thanks I'll give it a shot! Yup it worked !

Did you find this page helpful?