자바스크립트에는 부동소수점 숫자 문제가 있으므로 돈 관련 계산을 할 때는 항상 조심해야 합니
다. 가격을 센트 단위로 저장하면 도움이 되지만, 이 문제가 완전히 사라지지는 않습니다. 자바스크립트 새
버전에서는 재정 계산에 적합한
10
진 타입이 도입될 예정입니다.
이 코드로 우리는 몽구스로 만든
Vacation
모델 객체를 내보냈습니다. 이 모델을 애플리케이
션에서 사용할 때는 다음과 같이 불러옵니다.
var Vacation
=
require
('./
models
/
vacation
.
js
');
13.3.6.
초기 데이터 만들기
데이터베이스에는 휴가 패키지가 전혀 들어 있지 않으니 실습을 시작하려면 데이터를 준비해
야 합니다. 나중에는 제품을 관리할 방법을 만들어야겠지만, 일단 이 책에서는 코드로 입력하
겠습니다.
Vacation
.
find
(
function
(
err
,
vacations
){
if
(
err
)
return cosole
.
error
(
err
);
if
(
vacations
.
length
)
return
;
new Vacation
({
name
:
'
Hood River Day Trip
',
slug
:
'
hood
-
river
-
day
-
trip
',
category
:
'
Day Trip
',
sku
:
'
HR199
',
description
:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.