SeoMiYoung / CA_nodedotjs_mongodb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MongoDB에서 컬렉션 내의 문서들을 조회하는 두 가지 방법

SeoMiYoung opened this issue · comments

🔶 (1) 특정 조건에 맞는 첫 번째 문서 가져오기

// collection에 있는 조건에 맞는 가장 첫번째 document만 가져와주세요.
await db.collection('shopData').findOne({ a: 1 });

🔶 (2) 컬렉션 내의 모든 문서 가져오기

// collection에 있는 모든 document들 가져와주세요.
await db.collection('shopData').find().toArray();