-
V0.26 introduced a lot of very nice features! Thanks for such a good tool! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
This was answered in tweet: |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity, why would I want that? I need only the info if it was succesfully inserted, updated or deleted and the inserted id. I get all of that, e.g.: {
"fieldCount": 0,
"affectedRows": 1,
"insertId": 66,
"serverStatus": 2,
"warningCount": 1,
"message": "",
"protocol41": true,
"changedRows": 0
} And I still should have the object I've passed to Drizzle for all the other properties. If one wants to check if all objects were properly saved , a validation lib such as zod should be used before passing the data to Drizzle (hint: zod schemas or shapes can be derived from Drizzle!). |
Beta Was this translation helpful? Give feedback.
-
This reads better: function insertUser(userData: InsertUser): SelectUser {
return database.insert(users).values(...userData);
} Than this: async function insertUser(userData: InsertUser): SelectUser {
const insertedUserData = await database.insert(users).values(...userData);
return {
...userData,
id: insertedUserData.insertId
};
} It's just a convenience thing, as many apis are expected to return the inserted data in the post request. |
Beta Was this translation helpful? Give feedback.
This was answered in tweet:
MySQL does not provide returning and you always have to make an extra select and we don't do anything implicitly. That's a little less DX, but in a long run it's a win for everybody