如何透過 Sequlize 操作資料庫?
- Simple INSERT queries 
 官方範例:
 - const jane = await User.create({ firstName: "Jane", lastName: "Doe" });
 意思:在 User 資料庫裡新增一筆資料。firstName 叫 Jane,lastName 叫 Doe。回傳的結果存在- jane。
 記得- await只能放在- async function裡面。
- Simple SELECT queries 
 官方範例:- const users = await User.findAll();
 意思:撈出- User裡面全部的資料。回傳的結果存在- users。
 如果只想找一筆資料,像是想要比對使用者的帳號密碼輸入是否正確。- const user = await User.findOne({ where: { username, //ES6方便寫法 password } })- 意思:在 - User找到一筆 username = username, password = password的資料。
- Simple DELETE queries - await User.destroy({ where: { firstName: "Jane" } });- 刪除 - firstName: Jane的這筆資料。(不確定會不會相符的全刪?)
- Simple UPDATE queries - await User.update({ lastName: "Doe" }, { where: { lastName: null } });- 更新 - lastName: null的資料,更新為- lastName: "Doe"。不確定會不會相符的全部更新?)


![[ 筆記 ] CSS - 基礎樣式](https://static.coderbridge.com/img/krebikshaw/7ccd526d89d54a3db1fe20685ba25d02.jpg)
