jm_p_op
CRUD 본문
const models = require("../models")
//Create
models.User.create({column:value})
//Read
models.User,findAll({/**
* include: 모델 간의 관계 연결
* model : 어떤 모델인지 지정
* where: 쿼리 조건 설정 (id의 해당하는 유저가 쓴 댓글을 전체 조회)
*/
include:{column:value}
}).then((comment)=>console.log("검색결과",comment))
//Update
models.User.update({column:value},
{where:{column:value}})
//Delete
//여러개 동시 삭제 가능
models.User.destroy({where:{column:value}})
'Node.js > Express' 카테고리의 다른 글
DB - attributes 데이터 한정하기,보안 (0) | 2024.04.23 |
---|---|
DB 보안 - 해시 함수,hash 공격,salt,password 암호화 (0) | 2024.04.22 |
DB - sequelize-cli : DB-update (0) | 2024.04.14 |
DB - sequelize:up,down (0) | 2024.04.14 |
DB - seed 주의점2 (0) | 2024.04.14 |