#19 MongoDB
#19.0 Introduction
NOSQL_Not Only SQL, ๋ฐ์ดํฐ ์ ์ฅ ๋ฐฉ์์ด ๋ค๋ฆ, MongoDB, Redis, Neo...
MongoDB - JSON ๋ฌธ์ ํ์ฉ, ๋น๊ด๊ณํ ๋ฐ์ดํฐ๋ฒ ์ด์ค
#19.1 Installation
#19.2 Creating Documents
Easy, ๋ฐ์ดํฐ ํ์์ด๋ ์ ์ฝ์กฐ๊ฑด, ๊ตฌ์กฐ ๋ฑ SQL์ ์ ์ฝ์ด ์์ > ์ค์์ ๋ฏผ๊ฐํด์ง
cls - clear
#19.3 Reading Documents
db.movies.find({director:"Christopher Nolan"})
db.movies.find({rating: { $gte: 8 }})
// $gte ๊ฐ๊ฑฐ๋ ํฐ
db.movies.find({ year: { $gt: 2000, $lt: 2010}})
// and
db.movies.find({ $or: [{ rating: {$gt:9}}, {year: {$gte: 2020}})
// or
db.movies.find({ genres: { $in: ["Drama", "Crime"]}})
// ๋ฐฐ์ด ์์
db.movies.find({ genres: { $all: ["Drama", "Crime"]}})
// ๋ฐฐ์ด
db.movies.find({ title: { $regex: /the/i }})
// ์ ๊ทํํ์
db.movies.find({ genres: { $size: 3}})
// ํฌ๊ธฐ
db.movies.find({ director: { $exists: false }})
// ํน์ key ๊ฐ ์กด์ฌ
db.movies.find({ "cast.0": "Keanu Reeves"})
// ๋ฐฐ์ด ๋ด ์์ ๊ฐ
db.movies.find({ "director.alive": true })
// ์ค์ฒฉ๋ ๋ฌธ์ ๋ด๋ถ ๊ฒ์
db.movies.find().skip(10)
// skip
db.movies.find().limit(10).skip(10)
// limit
db.movies.find().sort({rating: 1}).limit(10).skip(10)
db.movies.find().sort({rating: -1}).limit(10).skip(10)
db.movies.find().sort({rating: -1, title: 1}).limit(10).skip(10)
// sort#19.4 Updating Documents
#19.5 Aggregating Documents
๋ฐ์ดํฐ ์ง๊ณ, group by์ ๋น์ทํจ
Last updated
Was this helpful?