Skip to Content
한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
book

한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것

by 한선용, 이선 브라운
May 2021
Beginner to intermediate
448 pages
9h 47m
Korean
Hanbit Media, Inc.
Content preview from 한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
227
13
지속성
않기 위해서입니다. 이미 저장된 패키지가 있다면 넘어갑니다. 하지만 첫 번째로 실행할 때는
find
에서 빈 리스트를 반환하므로 휴가 패키지 세 개를 만들고 각각
save
메서드를 호출합니
다.
save
메서드는 새 객체를 데이터베이스에 저장합니다.
이제 데이터베이스에 데이터가 저장됐으니 꺼내서 사용해봅시다.
13.3.8
데이터 가져오기
14
find
메서드로 패키지 리스트 전체를 가져오는 방법은 살펴봤습니다. 이번에는
find
에 옵션
을 전달해 데이터를 필터링해서 원하는 것을 찾는 방법을 알아봅시다. 현재 가용한 휴가 패키
지만 표시하고 싶습니다.
다음과 같이 상품 페이지 뷰
views
/
vacations
.
handlebars
를 만듭니다.
<h1>Vacations</h1>
{{#each vacations}}
<div class=”vacation”>
<h3>{{name}}</h3>
<p>{{description}}</p>
{{#if inSeason}}
<span class=”price”>{{price}}</span>
<a href=”/cart/add?sku={{sku}}” class=”btn btn-default”>Buy Now!</a>
{{else}}
<span class=”outOfSeason”>We’re sorry, this vacation ...
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.
Start your free trial

You might also like

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한성용, 이선 브라운

Publisher Resources

ISBN: 9791162244227