That is an excellent question, Muhammad! Unfortunately, when using MySQL, you are going to need to make another query request. Below are the steps 1. You insert the data *const newTodo = await pool.query("INSERT INTO todo (description) VALUES (?)", [description] );* 2. After running this query, it is going to return you back the last insert id. You can use this to make another request to get the data. *const todo = await pool.query("SELECT * FROM todo WHERE todo_id = ?", [newTodo[0].insertId]);*
Thank you for the tutorial! Very good explained! I watched your course on FCC, it was also awesome) PS: It'd be great if you made a tutorial on how to make simple full stack app with GraphQL using any of these graphql servers: apollo, yoga, express-graphql
Hi I have a question , if i just want to get the id of a todo how can i do that. Like I dont wanna return the id and the description like that res.json(totos[0]) but i wanna have the id. I tried this res.json(totos[0].id) but it didnt work
Hi, is there any way to return the data after insert or update the data into column with mysql ? Like you did in postgres tutorial using returning *
That is an excellent question, Muhammad! Unfortunately, when using MySQL, you are going to need to make another query request. Below are the steps
1. You insert the data
*const newTodo = await pool.query("INSERT INTO todo (description) VALUES (?)", [description] );*
2. After running this query, it is going to return you back the last insert id. You can use this to make another request to get the data.
*const todo = await pool.query("SELECT * FROM todo WHERE todo_id = ?", [newTodo[0].insertId]);*
That was awesome
Thank you for the tutorial! Very good explained! I watched your course on FCC, it was also awesome)
PS: It'd be great if you made a tutorial on how to make simple full stack app with GraphQL using any of these graphql servers: apollo, yoga, express-graphql
Thanks Rustam! Anyway that quite the combo you have there so I will definitely check it out . Thanks for the suggestion
Hi I have a question , if i just want to get the id of a todo how can i do that. Like I dont wanna return the id and the description like that res.json(totos[0]) but i wanna have the id. I tried this res.json(totos[0].id) but it didnt work
nice tutorial
Please make this tutorial with mssql (SQL Server), thanks.
I think it would be great to use adonis as well.
How to multi insert/update records?