node.js MongoDB Find - projection
MongoDB Find - projection
find()메서드의 두 번째 매개 변수 projection는 결과에 포함 할 필드를 설명하는 객체입니다.
이 매개 변수는 선택적이며, 생략하면 모든 필드가 결과에 포함됩니다.
예
customers 컬렉션에있는 모든 문서의 "name"및 "address"필드를 반환합니다.
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
dbo.collection("customers").find({}, { projection: { _id: 0, name: 1, address: 1 } }).toArray(function(err, result) {
if (err) throw err;
console.log(result);
db.close();
});
});
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4796 | jQuery | 8년 전 | 1533 | ||
| 4795 | jQuery | 8년 전 | 1435 | ||
| 4794 | jQuery | 8년 전 | 1562 | ||
| 4793 | jQuery | 8년 전 | 1620 | ||
| 4792 | jQuery | 8년 전 | 1623 | ||
| 4791 | jQuery | 8년 전 | 1794 | ||
| 4790 | jQuery | 8년 전 | 1735 | ||
| 4789 | jQuery | 8년 전 | 1598 | ||
| 4788 | jQuery | 8년 전 | 1660 | ||
| 4787 | jQuery | 8년 전 | 1475 | ||
| 4786 | jQuery | 8년 전 | 1434 | ||
| 4785 | jQuery | 8년 전 | 1644 | ||
| 4784 | jQuery | 8년 전 | 1521 | ||
| 4783 | jQuery | 8년 전 | 1228 | ||
| 4782 | jQuery | 8년 전 | 1598 | ||
| 4781 | jQuery | 8년 전 | 1338 | ||
| 4780 | jQuery | 8년 전 | 1574 | ||
| 4779 | jQuery | 8년 전 | 1983 | ||
| 4778 | jQuery | 8년 전 | 1957 | ||
| 4777 | jQuery | 8년 전 | 1528 | ||
| 4776 | jQuery | 8년 전 | 1582 | ||
| 4775 | jQuery | 8년 전 | 1971 | ||
| 4774 | jQuery | 8년 전 | 1484 | ||
| 4773 | jQuery | 8년 전 | 1410 | ||
| 4772 | jQuery | 8년 전 | 2201 | ||
| 4771 | jQuery | 8년 전 | 3608 | ||
| 4770 | PHP | 8년 전 | 5578 | ||
| 4769 | 기타 | 8년 전 | 1962 | ||
| 4768 | 기타 | 8년 전 | 1781 | ||
| 4767 | 기타 | 8년 전 | 2066 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기