Node.js/Sequelize

[ORM] ๐Ÿ“š ์‹œํ€„๋ผ์ด์ฆˆ - ์ฝ˜์†”์— ์ฟผ๋ฆฌ ๋กœ๊ทธ ๋„๊ธฐ

์ธํŒŒ_ 2022. 7. 30. 10:04

์‹œํ€„๋ผ์ด์ฆˆ-์ฟผ๋ฆฌ๋กœ๊ทธ

์ฝ˜์†”์— ์ฟผ๋ฆฌ ๋กœ๊ทธ ๋น„ํ™œ์„ฑํ™”

sequelize ๋ฉ”์†Œ๋“œ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ํ†ต์‹ ํ• ๋•Œ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ˜์†”์— ์ฟผ๋ฆฌ ๋กœ๊ทธ๊ฐ€ ๋œจ๊ฒŒ ๋œ๋‹ค.

ORM ๋งคํ•‘์ด ์ž˜๋˜์—ˆ๋‚˜ ์•ˆ๋˜์—ˆ๋‚˜ ๋””๋ฒ„๊น…ํ•˜๋Š” ์šฉ๋„๋กœ์จ๋Š” ๊ดœ์ฐฎ์ง€๋งŒ, ๋ฐ์ดํ„ฐ ํƒˆ์ทจ๋‚˜ ๋กœ๊ทธ ํŒŒ์ผ ์šฉ๋Ÿ‰ ์ ˆ์•ฝ์„ ์œ„ํ•ด์„œ ์ฟผ๋ฆฌ ๋กœ๊ทธ๋Š” ๊ฐœ๋ฐœ๋ชจ๋“œ์ผ ๋•Œ์—๋งŒ ์ฝ˜์†”์— ์ฐํžˆ๋Š”๊ฒŒ ์ข‹๋‹ค.

์‹œํ€„๋ผ์ด์ฆˆ-์ฟผ๋ฆฌ๋กœ๊ทธ

 

์ฟผ๋ฆฌ ๋กœ๊ทธ๋ฅผ ๋„๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

์‹œํ€„๋ผ์ด์ฆˆ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—ฐ๊ฒฐ ์˜ต์…˜์„ ์กฐ์ •ํ•˜๋Š” config.js ํŒŒ์ผ์— logging ์˜ต์…˜์„ ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.

module.exports = {
   development: {
      username: 'test',
      password: 123123,
      database: 'nodesns',
      host: '127.0.0.1',
      dialect: 'mysql',
   },
   production: {
      username: 'test',
      password: 123123,
      database: 'nodesns',
      host: '127.0.0.1',
      dialect: 'mysql',
      logging: false // ๋ฐฐํฌ ํ™˜๊ฒฝ์—์„œ๋Š” ์ฟผ๋ฆฌ ๋กœ๊ทธ๋ฅผ ๋น„ํ™œ์„ฑํ™” ํ•œ๋‹ค.
   },
};