Skip to content

bynodejs/mongoose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

mongoose

Index

  1. Docker

    • ๋ฆฌ๋ˆ…์Šค์˜ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ๋“ค์„ ์†Œํ”„ํŠธ์›จ์–ด ์ปจํ…Œ์ด๋„ˆ ์•ˆ์— ๋ฐฐ์น˜์‹œํ‚ค๋Š” ์ผ์„ ์ž๋™ํ™”ํ•˜๋Š” ์˜คํ”ˆ ์†Œ์Šค ํ”„๋กœ์ ํŠธ
      1. docker-compose up : ์‹คํ–‰ / docker-compose up -d : ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์‹คํ–‰

      2. docker-compose -f [docker-compose.yml(ํŒŒ์ผ๋ช…)] up -d : ํ•ด๋‹น ํŒŒ์ผ ์‹คํ–‰

      3. docker ps : ํ˜„์žฌ ๊ตฌ๋™ ํ™•์ธ

      4. docker-compose down : ์ข…๋ฃŒ

  2. NoSQL

    1. ์žฅ์ 

      • Flexibility : ์Šคํ‚ค๋งˆ๊ฐ€ ์—†๋Š” ๊ตฌ์กฐ๋ผ ์–ด๋–ค ํ˜•ํƒœ์˜ ๋ฐ์ดํ„ฐ๋ผ๋„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.

      • Performance : Read & Write ์„ฑ๋Šฅ์ด ๋›ฐ์–ด๋‚˜๋‹ค. ์บ์‹ฑ์ด๋‚˜ ๋งŽ์€ ํŠธ๋ž˜ํ”ฝ์„ ๊ฐ๋‹นํ•  ๋•Œ ์จ๋„ ์ข‹๋‹ค.

      • Scalability : ์Šค์ผ€์ผ ์•„์›ƒ ๊ตฌ์กฐ๋ฅผ ์ฑ„ํƒํ•ด์„œ ์‰ฝ๊ฒŒ ์šด์šฉ ๊ฐ€๋Šฅ, Auto sharding ์ง€์›

      • Deep Query ability : Query Language๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ SQL ๋งŒํผ ๊ฐ•๋ ฅํ•œ Query ์„ฑ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.

      • Conversion / Mapping : JSON ํ˜•ํƒœ๋กœ ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜์—ฌ ์ง๊ด€์ ์ด๊ณ  ๊ฐœ๋ฐœ์ด ํŽธ๋ฆฌํ•˜๋‹ค.

    2. ๋‹จ์ 

      • ์ •ํ•ฉ์„ฑ์ด ๋–จ์–ด์ง€๋ฏ€๋กœ ํŠธ๋žœ์žญ์…˜์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ์—๋Š” ๋ถ€์ ํ•ฉํ•˜๋‹ค. (ex: ๊ธˆ์œต, ๊ฒฐ์ œ, ํšŒ์›์ •๋ณด)

      • JOIN ๊ธฐ๋Šฅ์ด ์—†๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ JOIN์ด ํ•„์š”์—†๋„๋ก ๋ฐ์ดํ„ฐ ๊ตฌ์กฐํ™” ํ•„์š”

      • memory mapped file์œผ๋กœ ํŒŒ์ผ ์—”์ง„ DB์ด๋‹ค. ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ๋ฅผ OS์—๊ฒŒ ์œ„์ž„ํ•œ๋‹ค. ์ฆ‰, ๋ฉ”๋ชจ๋ฆฌ ํฌ๊ธฐ๊ฐ€ ์„ฑ๋Šฅ์„ ์ขŒ์šฐํ•œ๋‹ค.

    3. ๊ตฌ์กฐ

      • document : { 'key' : value } ๊ตฌ๋กœ์˜ค ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ value์—๋Š” ๋˜ ๋‹ค์‹œ document๊ฐ€ ๋“ค์–ด๊ฐˆ์ˆ˜์žˆ๋‹ค.

      • ๋˜ํ•œ ๋™์  ์Šคํ‚ค๋งˆ๋ฅผ ๊ฐ–๊ณ  ์žˆ์–ด์„œ, collection(ํ…Œ์ด๋ธ”)์•ˆ์— ์žˆ๋Š” document๋ผ๋ฆฌ ๋‹ค๋ฅธ ์Šคํ‚ค๋งˆ๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.(์Šคํ‚ค๋งˆ ํ”„๋ฆฌ)

      • primary key(objectId) : objectId๋Š” 12bytes 16์ง„์ˆ˜ ๊ฐ’์œผ๋กœ document์˜ ์œ ์ผ์„ฑ์„ ๋ณด์žฅํ•œ๋‹ค. ์ˆœ์„œ๋Œ€๋กœ 4bytes timestamp, 3bytes machine id, 2bytes ํ”„๋กœ์„ธ์ŠคId, 3bytes ์ˆœ์ฐจ๋ฒˆํ˜ธ = index(auto_increment)

      • collection : document์˜ ๊ทธ๋ฃน์ด๋ฉฐ, document๋“ค์ด collection ๋‚ด๋ถ€์— ์œ„์น˜ํ•˜๊ณ  ์žˆ๋‹ค.

      • database : collection๋“ค์˜ ๋ฌผ๋ฆฌ์ ์ธ ์ปจํ…Œ์ด๋„ˆ์ด๋‹ค. ๊ฐ database๋Š” ํŒŒ์ผ์‹œ์Šคํ…œ์— ์—ฌ๋ŸฌํŒŒ์ผ๋“ค๋กœ ์ €์žฅ๋œ๋‹ค.

  3. mongoose

    • ODM (Object Document Mapping)

    • node_modules schema ์ƒ์„ฑํ•œ๋‹ค.

    • schema๋ฅผ object ๊ตฌ์กฐ๋กœ ๋งŒ๋“ ๊ฒŒ model์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.

  4. Database Tools

  5. mongoDB Cloud

Modules

Link