2016-12-08 13 views
0

$inクエリをmongoDBの集計とともに作成するにはどうすればよいですか?私は

SELECT name,count(something) from collection1 
where name in (<<list of Array>>) and cond1 = 'false' 
group by name 

答えて

0

同等のmongoクエリの下にSQLの等価MongoDBのクエリを書きたい、次のとおりです。

db.collection1.aggregate([ 
    { "$match": { "name": { "$in": arrayList } } }, 
    { 
     "$group": { 
      "_id": "$name", 
      "count": { "$sum": "$something" } 
     } 
    } 
])