Stack Overflow Asked by 1005hoon on December 11, 2021
I’m currently studying MongoDB from MongoDB University’s free online courses.
Well, I’m working on part aggregation and tried writing aggregation query for the tutorial.
// 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});
Well, for me those two look identical! but the one that I wrote wont print out the solution 🙁
Could anyone tell me whats wrong with mine?
Thanks !
this is the sample db
mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/aggregations?replicaSet=Cluster0-shard-0" –authenticationDatabase admin –ssl -u m121 -p aggregations –norc
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP