#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?