InferSelectModel vs. InferInsertModel

I couldn’t find any documentation on what the differences are. My best guess is maybe the insert type might not require auto incremented primary keys and other generated fields since you don’t have them on insert?
6 Replies
Angelelz
Angelelz17mo ago
Correct
ChaloVega
ChaloVega15mo ago
hello, i'm new here and i have a question about this. My column is id: smallserial("id").primaryKey() but when i use $inferInsert, i do have the id field, which of course i don't have when inserting. I'm i missing something in my table definition?
Angelelz
Angelelz15mo ago
It should be number | undefined. So you can just not provide it
ChaloVega
ChaloVega15mo ago
it's not, it's just number
Angelelz
Angelelz15mo ago
That's not supposed to happen. Can you put together a small repro repo?
ChaloVega
ChaloVega15mo ago
i just found this https://github.com/drizzle-team/drizzle-orm/issues/663. I was able to solve my problem by changing smallserial to serial
GitHub
Issues · drizzle-team/drizzle-orm
TypeScript ORM that feels like writing SQL. Contribute to drizzle-team/drizzle-orm development by creating an account on GitHub.
Want results from more Discord servers?
Add your server