Build restful API with MySQL and NodeJS

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 พ.ย. 2024

ความคิดเห็น • 10

  • @muhammadnurali4347
    @muhammadnurali4347 4 ปีที่แล้ว +1

    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 *

    • @TheQuackLearner
      @TheQuackLearner  4 ปีที่แล้ว +3

      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]);*

  • @amgedalmogahed8438
    @amgedalmogahed8438 2 ปีที่แล้ว

    That was awesome

  • @frixaco
    @frixaco 4 ปีที่แล้ว +2

    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

    • @TheQuackLearner
      @TheQuackLearner  4 ปีที่แล้ว +1

      Thanks Rustam! Anyway that quite the combo you have there so I will definitely check it out . Thanks for the suggestion

  • @realche3352
    @realche3352 3 ปีที่แล้ว

    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

  • @mohammadrasel1271
    @mohammadrasel1271 4 ปีที่แล้ว

    nice tutorial

  • @sokealy5003
    @sokealy5003 4 ปีที่แล้ว

    Please make this tutorial with mssql (SQL Server), thanks.

  • @gabrielnascimento4394
    @gabrielnascimento4394 4 ปีที่แล้ว

    I think it would be great to use adonis as well.

  • @sokealy5003
    @sokealy5003 4 ปีที่แล้ว

    How to multi insert/update records?