What is wrong with this query? I tried to run it on mongodb server and received an error as following - \"exception: bad query: BadValue unknown top level operator: $gte\".
You did this wrong. Should be:
db.scores.aggregate([
{ "$match": {
"score": { "$gte": 30, "$lte": 60 }
}},
{ "$group": {
"_id": "$gamer",
"games": { "$sum": 1 }
}}
])
Which is the proper way to specify a "range" query where the actual conditions are "and" and therefore "between" the operands specified.