내배캠 73일차

·2023년 1월 25일
0

내일배움캠프

목록 보기
79/142
post-thumbnail

typescript_hard

사용한 github주소

기본설정

package.json

설정한 파일들을 실행시실 스크립트를 만듭니다. 개인적으로 파일이 재실행 될 때마다 나오는 메세지를 --quiet또는 -q 라는 flag로 감춰줍니다.

"start:dev": "npx nodemon -q"

선발대

엔티티와 엔티티의 관계(릴레이션)

1:1
사람(이름) - 주민번호
1:N
작성자 - 게시글
N:M
세탁업소 - 세탁물, 차량 - 차량 색

모델링시 기본 원칙

  • 업무에서 필요한 모든 데이터가 모델에 정의 되어야 함!
  • 두 개의 엔티티가 비슷한 어트리부트로 구성이 되어있으면 하나의 엔티티로 통합
  • 어트리부트는 누구나 알 수 있도록 작성되어야 함
  • 어트리부트 이름은 너무 길게 작성 ㄴㄴ
  • 어트리부트가 여러개의 값을 가지게 되면 엔트리롤 바꾸는 것이 낫다
  • 엔티티ㅡ 어트리부트는 명사이고 관계는 동사이다
  • Data Redundancy(데이터중복) 이슈가 발생 ㄴㄴ

인덱스

: 데이터베이스 테이블의 검색 속도를 향상시키기 위한 자료구조

  • 테이터베이스의 본질은 빠르게 원하는 데이터를 탐색하여 가지고 오기 위함 => 인덱스
  • 인덱스를 구현할 수 있는 자료구조
    • B-트리 : 검색속도 O(logN), balanced, boeing, bayer
  • 해시테이블 : 검색속도 O(1) = 수행시간

정예반

사용한 github주소

module

아래와 같이 사용해서 app.js의 movies, users를 파일을 만들어 불러와 줄 것!

module.js : 내보낼

// const messages = ["hello world!", "안녕하세요"];
// const messages = { en: "hello world!", kr: "안녕하세요" };
// module.exports = messages

// const addition = (x, y) => x + y;
// module.exports = addition;

module.exports = {
  addition: (x, y) => x + y,
  multiple: (x, y) => x * y,
};

main.js : 불러올

//// module.exports
// const messages = require("./module");
// const lang = "en";
// console.log(messages);
// console.log(`zoo, ${messages[lang]}`); // zoo, hello world!

//// 객체구조분해할당
// const { en } = require("./module");
// console.log(`zoo, ${en}`); // zoo, hello world!

// //sum
// const sum = require("./module");
// console.log(sum(1, 2)); // 3

const Math = require("./module");
console.log(Math.addition(2, 5)); //7
console.log(Math.multiple(2, 5)); //10

// const { addition, multiple } = require("./module");
// console.log(addition(1, 5), multiple(2, 6)); //6, 12

function

function은 하나당 한 기능을 사용하는 것이 일반적!

fn.js

const currencyByCountry = {
  en: {
    format: "en-US",
    currency: "USD",
  },
  kr: {
    format: "kr-KO",
    currency: "KRW",
  },
};

const numberToCurrency = (number, countryCode) => {
  const cur = currencyByCountry[countryCode];
  return new Intl.NumberFormat(cur.format, {
    style: "currency",
    currency: cur.currency,
  }).format(number);
};

const priceToKrwFormat = (price, country) => {
  const countryCode = country || "kr";
  return {
    priceKrw: numberToCurrency(price, countryCode),
    tax: numberToCurrency(Math.round((price / 11) * 10), countryCode),
    originalPrice: numberToCurrency(Math.round(price / 11), countryCode),
  };
};

console.log(priceToKrwFormat(100000, "kr"));
console.log(priceToKrwFormat(100000));
console.log(priceToKrwFormat(100000, "en"));
profile
개발자 꿈나무

0개의 댓글