[node] Sequelize에서의 모델 작성


[node] Sequelize에서의 모델 작성

models 하위 폴더에 products.js 를 생성한다. 생성한 파일에 아래와 같이 코딩한다. sql문의 Create와 비슷하다고 보면 된다. module.exports = function(sequelize, DataTypes){ const Products = sequelize.define('Products', { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, name : { type: DataTypes.STRING }, price : { type: DataTypes.INTEGER }, description : { type: DataTypes.TEXT } } ); return Products; } products.js app.js로 돌아가 dbConnection() 함수 중 sync 부분에 해당 소스를 추가해준다. return db.sequelize.sync(); cmd창에서 실행 시 product...


#create #javascript #model #node #nodejs #sequelize #노드 #모델 #시퀄라이즈

원문링크 : [node] Sequelize에서의 모델 작성