6
Bu sorgudaki sorun nedir? Ben mongodb sunucu üzerinde çalıştı ve aşağıdaki gibi bir hata aldı - "istisna: kötü sorgu: BadValue bilinmeyen üst düzey operatör: $ gte". Bana neyin yanlış olduğunu söyleyen var mı lütfen?
db.scores.aggregate([
{
$match: {
$or: [
{ $gte: [ "$score", 30 ] },
{ $lte: [ "$score", 60 ] }
]
}
},
{
$group: {
_id: "$gamer",
games: { $sum: 1 }
}
}
])
örnek veriler:
{
"_id" : "545665cef9c60c133d2bce72",
"score" : 85,
"gamer" : "Latern"
}
/* 1 */
{
"_id" : "545665cef9c60c133d2bce73",
"score" : 10,
"gamer" : "BADA55"
}
/* 2 */
{
"_id" : "545665cef9c60c133d2bce74",
"score" : 62,
"gamer" : "BADA55"
}
/* 3 */
{
"_id" : "545665cef9c60c133d2bce75",
"score" : 78,
"gamer" : "l00ser"
}
/* 4 */
{
"_id" : "545665cef9c60c133d2bce76",
"score" : 4,
"gamer" : "l00ser"
}
/* 5 */
{
"_id" : "545665cef9c60c133d2bce77",
"score" : 55,
"gamer" : "FunnyCat"
}
['$ match' sorgusu sözdizimini alır] (https://docs.mongodb.org/manual/reference/operator/aggregation/match/) olması nedeniyle kritik nokta [sorgu' $ 'ı kullanmak istersiniz. gte 'operatörü] (https://docs.mongodb.org/manual/reference/operator/query/gte/) ve [aggregation' gte 'operatörünü değil] (https://docs.mongodb.org/manual/ referans/operatör/yığılması/GTE /). (BTW, [range query] (https://docs.mongodb.org/manual/reference/method/db.collection.find/#query-for-ranges) [implicit '$ ve'] kullanımıyla çalışır (https://docs.mongodb.org/manual/reference/operator/query/and/)). – duozmo