我目前正在从 MongoDB 大学的免费在线课程学习 MongoDB。
好吧,我正在研究部分聚合,并尝试为教程编写聚合查询。
// This is what I wrote
db.solarSystem.aggregate([{
"$match": {
"atmosphericComposition": { "$in": [/02/]},
"meanTemperature": { $gte: -40, "$lte": 40 }
}
}, {
"$project": {
"_id": 0,
"name": 1,
"hasMoons": { "$gt": ["$numberOfMoons", 0] }
}
}], { "allowDiskUse": true})
// This is what's given as solution
db.solarSystem.aggregate([{
"$match": {
"atmosphericComposition": { "$in": [/O2/] },
"meanTemperature": { $gte: -40, "$lte": 40 }
}
}, {
"$project": {
"_id": 0,
"name": 1,
"hasMoons": { "$gt": ["$numberOfMoons", 0] }
}
}], { "allowDiskUse": true});
好吧,对我来说,这两个看起来一样!但是我写的那个不会打印出解决方案:(
谁能告诉我我有什么问题?谢谢!
这是示例 db mongo "mongodb:/ / cer0-shard-00-00-jxeqq.mongodb.net:27017,cer0-shard-00-01-jxeqq.mongodb.net:27017,cer0-shard-00-02-jxeqq.mongodb.net:27017 / aggreat
本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处
评论列表(49条)