Page 300 - Nodejs 교과서 개정2판
P. 300
ઁ द௬ۄૉী ਃೠ TFRVFMJ[F৬ TFRVFMJ[F DMJ NZTRM ಁఃܳ ࢸפ
콘솔
$ npm i express morgan nunjucks sequelize sequelize-cli mysql2
$ npm i -D nodemon
TFRVFMJ[F DMJח द௬ۄૉ ݺ۸যܳ प೯ೞӝ ਤೠ ಁఃҊ NZTRM ח .Z42-җ द௬ۄૉܳ যח
٘ۄߡੑפ NZTRM о ؘఠ߬झ ۽Ӓ۔ ইפ۽ য়೧ೞݶ উ ؾפ
ࢸ ৮ܐ റ sequelize init ݺ۸যܳ ഐೞݶ ؾפ ࢸ হ ݺ۸য۽ ࢎਊೞ۰ݶ খী npxܳ ࠢ
ݶ ؾפ
콘솔
$ npx sequelize init
Sequelize CLI [Node: 14.0.0, CLI: 6.1.0, ORM: 6.2.3]
Created "config\config.json"
Successfully created models folder at ...
Successfully created migrations folder at ...
Successfully created seeders folder at ...
DPOGJH NPEFMT NJHSBUJPOT TFFEFST ಫ؊о ࢤࢿغणפ NPEFMT ಫ؊ উ JOEFY KTо ࢤࢿغח
ഛੋפ TFRVFMJ[F DMJо زਵ۽ ࢤࢿ೧ח ٘ח Ӓ۽ ࢎਊೡ ٸ ী۞о ߊࢤೞҊ ਃ হח ࠗ࠙ب
݆ਵ۽ җ э ࣻפ
models/index.js
const Sequelize = require('sequelize');
const env = process.env.NODE_ENV || 'development';
const config = require('../config/config')[env];
const db = {};
const sequelize = new Sequelize(config.database, config.username, config.password, config);
db.sequelize = sequelize;
module.exports = db;
Sequelizeח द௬ۄૉ ಁః ࢤࢿੑפ DPOGJH DPOGJH KTPOীࢲ ؘఠ߬झ ࢸਸ ࠛ۞ৡ റ O
FX Sequelizeܳ ా೧ .Z42- োѾ ёܳ ࢤࢿפ োѾ ёܳ աী ࢎਊೞӝ ਤ೧ db.sequelizeী
֍যفणפ