Node.js (express, mongoose, etc.)
[20180628THU]
- req, res๋ฅผ ์ฌ์ฉํ์ฌ ํต์ ํ๋ ๊ฒ์ Ajax๋ฐฉ์์ด๋ผ๊ณ ํจ (X์๋X) => ํ์ด์ง ์ ์ฒด reload์์ด ํด๋น ๋ถ๋ถ๋ง์ renderํ๋ ๋ฐฉ์
- const ์ด๋ฆ = require('๋ชจ๋'); / module.export = ๋ชจ๋
- routing: get, post ๋ฑ ํ URL์ ๋ํด ๋ฐฉ์ ๋ผ์ฐํ ์ ๋ค๋ฅด๊ฒ ํ ์ ์์
- app.get('/', callback); ๋๋ app.route('/').get(callback).post(callback);
- ์ ์ ๋๋ ์์ฒญ์ด ์ด๋ค ๋ฐฉ์์ธ์ง ๋ณด๋ด๋ ํ์ผ์์
- res.render('ํ์ด์ง');
- ์๋ต ๋งค์๋๋ render๋ง๊ณ ๋ download, end, json, jsonp, redirect, send, sendFile, sendSatus๊ฐ ์์
[20180629FRI]
- express.Router ๋ชจ๋์ ๋ง์ดํ ? => const router = require('express').Router();
- MongoDB download, execute, connect!
- models์์ Schema ์์ฑ
[20180702MON]
- models\school.js> use statics for defining functions in model file
- routes\index.js> 1. statics ์ฌ์ฉ
- app.js> app.use('/', index); : '/'์ ๋ํ ์์ฒญ์ routes\index.js๋ก route
[20180704WED]
- install git bash: connect local repository to remote / first commit
- create README.md
- form ํ๊ทธ์ action -> routes\index.js์์ ์ฐพ์์ ์คํ ?(query) / =(param) req.query.์ด๋ฆ
- statics ์ฌ์ฉํ ๋ then(), catch()? => statics์์ return๋ ๊ฐ์ด then์ผ๋ก
[20180705THU]
- ๊ฒ์ ๊ฒฐ๊ณผ๊ฐ ์์ผ๋ฉด renderํ searcherr.ejs viewํ์ด์ง ์์ฑ
- post๋ฐฉ์์ ํตํด DB์ ๋ฐ์ดํฐ ์ถ๊ฐ... ํ๊ณ ์ถ๋ค.
- schoolSchema.statics.create์์ new this๊ฐ ์๋จ
- new schoolSchema๋ ์๋จ => not constructor
[20180706FRI]
- DB์ ๋ฐ์ดํฐ ์ถ๊ฐ 3) mongoose.model์ด ์์ฑ์๋ฅผ ์์ฑ -> mongoose.model์ new mongoose.schema ๋ฐ๋ก ๋ค์์ผ๋ก -> schoolSchema.statics.findOneByName์ด ํจ์์ ๊ธฐ๋ฅ์ ์์ 4) schoolSchema.statics.create ์ ์ mongoose.model -> ๋ฐ์ดํฐ ์ถ๊ฐ ์๋จ -> ์ธ์ค ์์์ผ๋ viewํ์ด์ง ์์ ํ ์๋ +) ๋ง์ ์๋ฆ
- findOneByName์ ํด๋น name์ ๊ฐ์ง ๋ฐ์ดํฐ๋ฅผ ํ๋๋ง ์ฐพ์ ์ ์์ -> findOneByName์ findOne ๋์ find ์ฌ์ฉ, ์ด๋ฆ์ findByName์ผ๋ก ๋ณ๊ฒฝ -> ์๋ ๋ฐ์ดํฐ ๊ฒ์ ์ searcherr render ์คํจ (๋น ๋ฐฐ์ด boolean == true) => ๋น ๋ฐฐ์ด.length boolean == false
[20180707SAT] ์์ฑ!
[20180709MON]
- All ๋ฒํผ ์์ => ์ง์ง ์์ฑ!