JX405기_비트/mongoDB

Day17-2 MongoDB 연습 문제3

_하루살이_ 2023. 2. 8. 13:44

1. db.restaurants.find({},{restaurant_id:1, name:1, borough:1, cuisine:1})

2. db.restaurants.find({},{restaurant_id:1, name:1, borough:1, cuisine:1,_id:0})

3. db.restaurants.find({borough:"Bronx"})

4. db.restaurants.find({borough:"Bronx"}).limit(5)

5. db.restaurants.find({borough:"Bronx"}).skip(5).limit(5)

6. db.restaurants.find({"grades.score":{$gte:90}})

7. db.restaurants.find({"grades.score":{$gte:80, $lt:100}})

8. db.restaurants.find({"address.coord.0":{$lt:-95.754168}})

9. db.restaurants.find({cuisine:{$ne:"American"},"grades.score":{$gte:70},"address.coord.0":{$lt :-65.754168}})

10. db.restaurants.find({cuisine:{$ne:"American"},"grades.grade":"A",borough:{$ne:"Brooklyn"}}).sort({cuisine:-1})

11. db.restaurants.find({ name : /ces$/ },{restaurant_id:1, name:1, borough:1, cuisine:1}) 

13. db.restaurants.find({ name : /ces$/ },{restaurant_id:1, name:1, borough:1, cuisine:1}) 

14. db.restaurants.find({ name : /Reg/ })

15. db.restaurants.find({"grades":{$elemMatch :{date :{$eq:ISODate("2014-08-11T00:00:00Z")}, score:{$eq:11}, grade: 'A'}}})

16. db.restaurants.find({"grades.1.date":ISODate("2014-08-11T00:00:00Z"), "grades.1.score" : {$eq:9}, "grades.1.grade": 'A'})

17. db.restaurants.find({"address.street":{$ne: null}}) ? db.restaurants.find({"address.street":{$exist: true}})