大学代码查询:MongoDB聚合查询从 MongoDB大学课程

我目前正在从 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

本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处

(209)
快穿无cp无攻略:运行无头铬 /木偶与-无沙箱(sandbox run)
上一篇
端口查询:elasticsearch嵌套范围查询
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(49条)