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ী

         ֍যف঻णפ׮

          
   295   296   297   298   299   300   301   302   303   304   305