2016-12-08 3 views
0

Wie schreibe ich eine $in Abfrage zusammen mit Aggregat in MongoDB? Ich möchte unter

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

Antwort

0

Die äquivalente Mongo Abfrage eine äquivalente mongoDB Abfrage für die SQL schreiben folgt:

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