Node Sequelize basic CRUD

Let's see the CRUD operations with sequelize

Create

await User.create({firstName, lastName})

Find

To find all data

User.findAll()

To find specific data

User.findAll({where:{id:3}})

To find only the needed attribute we can use keyword attributes and provide the array of fields that we needed.

await User.findAll({attributes:['firstName']})

Update

In update first provide the new values and then say where you need to update

await User.update({firstName}, {where:{id:1}})

Delete

await User.destroy({where:{id:1}})