Question about primary key #1786
Replies: 1 comment
-
Unfortunately, it's impossible. It's not just impossible because I didn't implement it yet, it's conceptionally impossible and the main motivation companions were added in the first place. As you mentioned, the primary key can't just be set to So, the general principal is that data classes exist to represent full rows in the database, and companions exists to represent partial rows (which is needed for updates or inserts). They're designed for different problems. Sometimes, inserting a data class into the database can be fine, but in general I recommend using companions. If you want to have an API that supports both data classes and companions, use |
Beta Was this translation helpful? Give feedback.
-
How to use a data class itself (so no companion) to insert a row in the database?
I can't get it to work because the primary key can't be
null
.Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions