2014-11-07 5 views
0

다음과 같은 형식의 컬렉션이있는 mongoDB (Mongoose 미들웨어 사용)를 사용하고 있습니다. 해당 모음에 mongoDB에서 코드 쿼리를 작성하는 방법은 무엇입니까?

{ _id : ObjectId("1"), tag: 'A038', flag: 'P', size: 60, name: 'productA' } 
{ _id : ObjectId("2"), tag: 'A038', flag: 'R', size: 60, name: 'productA' } 
{ _id : ObjectId("3"), tag: 'A039', flag: 'P', size: 60, name: 'productA' } 
{ _id : ObjectId("4"), tag: 'A040', flag: 'P', size: 60, name: 'productA' } 
{ _id : ObjectId("5"), tag: 'A040', flag: 'R', size: 60, name: 'productA' } 
{ _id : ObjectId("6"), tag: 'A041', flag: 'P', size: 60, name: 'productA' } 
{ _id : ObjectId("7"), tag: 'A042', flag: 'P', size: 60, name: 'productA' } 

, 어떻게 MongoDB의에서 코드를 작성 쿼리가? 이렇게 레코드를 얻으십시오.

{ _id : ObjectId("3"), tag: 'A039', flag: 'P', size: 60, name: 'productA' } 
{ _id : ObjectId("6"), tag: 'A041', flag: 'P', size: 60, name: 'productA' } 
{ _id : ObjectId("7"), tag: 'A042', flag: 'P', size: 60, name: 'productA' } 

mongodb에서 가능합니까?

어떤 쿼리가 당신이 쓴 않았다

WJ

+0

감사합니다? – monkeyinsight

답변

0
collection.find({_id:{"$in":[ObjectId("3"),ObjectId("6"),ObjectId("7")]}},function(err,results){ 
console.log(results); 
}) 
관련 문제