데이터베이스

몽고 DB 쿼리 - 연습과제

syleemomo 2024. 4. 23. 14:43
728x90

연습과제 1

db.movies.find({ title: { $regex: /er/ }}).count()

연습과제 2

db.movies.find( { year: { $gt: 2020 }}).count()

연습과제 3

 db.movies.find({ year: { $gte: 2005,  $lte: 2007 }}).count()

연습과제 4

db.movies.find({ genres: { $in: ["Comedy", "Horror"] }}).count()

연습과제 5

db.movies.find({ runtime: { $mod: [5, 0] }}).count()

 

연습과제 6

 db.movies.find({ $and: [{ rating: { $gt: 7 } }, { year: { $gt: 2020 } }] }).count()

 

연습과제 7

 db.movies.find({ summary: { $regex: /in the/ }}).count()

 

연습과제 8

db.movies.find( { language: { $in: ["nl", "pt"] }}).count()

연습과제 9

db.movies.find({ genres: "Romance", year: { $gt: 2015, $lt: 2023 } }).count()

연습과제 10

db.movies.find({ $where: function(){ return this.title.length < 12 }}).count()

연습과제 11

db.movies.find({ $nor: [{ year: { $lt: 2013}}, {runtime: { $lt: 100}}]}).count()

연습과제 12

db.movies.find({ genres: { $nin: ["Horror", "Action", "Romance", "Drama", "Mystery"] }}).count()

연습과제 13

 db.movies.find({ $where: function(){ return this.genres.length === 4 }}).count()

연습과제 14

db.movies.find({ $where: function(){ return this.title.split('-').length === 3 }}).count()
db.movies.find({ title: { $regex: /-.-/ }})

연습과제 15

db.movies.find({ title: { $regex: /:/ }}).count()
728x90