Skip to content

shinerd/myfirstWeb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

myfirstWeb

Node.js (express, mongoose, etc.)

[20180628THU]

  1. req, res๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ†ต์‹ ํ•˜๋Š” ๊ฒƒ์„ Ajax๋ฐฉ์‹์ด๋ผ๊ณ  ํ•จ (X์•„๋‹˜X) => ํŽ˜์ด์ง€ ์ „์ฒด reload์—†์ด ํ•ด๋‹น ๋ถ€๋ถ„๋งŒ์„ renderํ•˜๋Š” ๋ฐฉ์‹
  2. const ์ด๋ฆ„ = require('๋ชจ๋“ˆ'); / module.export = ๋ชจ๋“ˆ
  3. routing: get, post ๋“ฑ ํ•œ URL์— ๋Œ€ํ•ด ๋ฐฉ์‹ ๋ผ์šฐํŒ…์„ ๋‹ค๋ฅด๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Œ
  4. app.get('/', callback); ๋˜๋Š” app.route('/').get(callback).post(callback);
  5. ์ ‘์† ๋˜๋Š” ์š”์ฒญ์ด ์–ด๋–ค ๋ฐฉ์‹์ธ์ง€ ๋ณด๋‚ด๋Š” ํŒŒ์ผ์—์„œ
  6. res.render('ํŽ˜์ด์ง€');
  7. ์‘๋‹ต ๋งค์†Œ๋“œ๋Š” render๋ง๊ณ ๋„ download, end, json, jsonp, redirect, send, sendFile, sendSatus๊ฐ€ ์žˆ์Œ

[20180629FRI]

  1. express.Router ๋ชจ๋“ˆ์‹ ๋งˆ์šดํŒ…? => const router = require('express').Router();
  2. MongoDB download, execute, connect!
  3. models์—์„œ Schema ์ž‘์„ฑ

[20180702MON]

  1. models\school.js> use statics for defining functions in model file
  2. routes\index.js> 1. statics ์‚ฌ์šฉ
  3. app.js> app.use('/', index); : '/'์— ๋Œ€ํ•œ ์š”์ฒญ์„ routes\index.js๋กœ route

[20180704WED]

  1. install git bash: connect local repository to remote / first commit
  2. create README.md
  3. form ํƒœ๊ทธ์˜ action -> routes\index.js์—์„œ ์ฐพ์•„์„œ ์‹คํ–‰ ?(query) / =(param) req.query.์ด๋ฆ„
  4. statics ์‚ฌ์šฉํ•  ๋•Œ then(), catch()? => statics์—์„œ return๋œ ๊ฐ’์ด then์œผ๋กœ

[20180705THU]

  1. ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์œผ๋ฉด renderํ•  searcherr.ejs viewํŽ˜์ด์ง€ ์ƒ์„ฑ
  2. post๋ฐฉ์‹์„ ํ†ตํ•ด DB์— ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€... ํ•˜๊ณ  ์‹ถ๋‹ค.
    1. schoolSchema.statics.create์—์„œ new this๊ฐ€ ์•ˆ๋จ
    2. new schoolSchema๋„ ์•ˆ๋จ => not constructor

[20180706FRI]

  1. DB์— ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€ 3) mongoose.model์ด ์ƒ์„ฑ์ž๋ฅผ ์ƒ์„ฑ -> mongoose.model์„ new mongoose.schema ๋ฐ”๋กœ ๋‹ค์Œ์œผ๋กœ -> schoolSchema.statics.findOneByName์ด ํ•จ์ˆ˜์˜ ๊ธฐ๋Šฅ์„ ์žƒ์Œ 4) schoolSchema.statics.create ์ „์— mongoose.model -> ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€ ์•ˆ๋จ -> ์ธ์ค„ ์•Œ์•˜์œผ๋‚˜ viewํŽ˜์ด์ง€ ์ˆ˜์ • ํ›„ ์ž‘๋™ +) ๋ง˜์— ์•ˆ๋“ฆ
  2. findOneByName์€ ํ•ด๋‹น name์„ ๊ฐ€์ง„ ๋ฐ์ดํ„ฐ๋ฅผ ํ•˜๋‚˜๋งŒ ์ฐพ์„ ์ˆ˜ ์žˆ์Œ -> findOneByName์— findOne ๋Œ€์‹  find ์‚ฌ์šฉ, ์ด๋ฆ„์„ findByName์œผ๋กœ ๋ณ€๊ฒฝ -> ์—†๋Š” ๋ฐ์ดํ„ฐ ๊ฒ€์ƒ‰ ์‹œ searcherr render ์‹คํŒจ (๋นˆ ๋ฐฐ์—ด boolean == true) => ๋นˆ ๋ฐฐ์—ด.length boolean == false

[20180707SAT] ์™„์„ฑ!

[20180709MON]

  1. All ๋ฒ„ํŠผ ์ˆ˜์ • => ์ง„์งœ ์™„์„ฑ!

About

Node.js (express, mongoose, etc.)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors