Is there a short form for insert and get? Where I ...
# exposed
a
Is there a short form for insert and get? Where I want to get not just a column but the entire row
t
Entire row of what? Most of the time insert returns only autoGenerated keys + default values generated by Exposed.
a
I would like the outcome of I were to query again using the generated ID. For example, if I have a table with an auto generated id, name, and date of création, I'd like to insert a new entry with just the name and be able to get the entire model of id name and date back as they are auto generated. Is the only solution that I should be creating the values myself before inserting, if I don't want to do an insert and get and deal with potential failures?
t
@Allan Wang, there two possible way to declare default column values: clientDefault - when value generated from code, dbDefault - value will be created on db side. If you use clientDefault then it’s possible to achieve values just after insert otherwise you should make additional select by id as not every DB has option to return values.
a
My original question was just if there was an insertAndGet method that returns more than the id. Currently I'm using clientDefault and I'm inserting and then calling get as two separate calls.