Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MongoDB Basic
Search
yuanxin.qiu
August 28, 2013
Technology
79
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MongoDB Basic
Rails Night 文档,MongoDB,
http://floating-brook-3473.herokuapp.com/activities/14
yuanxin.qiu
August 28, 2013
More Decks by yuanxin.qiu
See All by yuanxin.qiu
MongoDB Basic
star
0
100
Other Decks in Technology
See All in Technology
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
170
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
3
150
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
340
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
290
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
130
20260903 Tokyo Jazug Night #62 | Azure エンジニアよ、 その環境は本当にセキュアか?
olivia_0707
1
640
module Synths; end
asonas
1
130
Kiro Crewしか勝たん!?
miu_crescent
PRO
0
190
推論の観測、できていますか? 〜 Google Cloud Gemini Enterprise Agent Platformで 3つの Gemini モデルを実測して踏んだ、評価の罠 〜
shukob
PRO
0
180
多摩川(.dev)ランニング入門 / Tamagawa.dev#3
fujiwara3
3
410
AIで仕事のやり方を変える
matsu7874
3
1k
Snowflakeのコスト最適化を支えるアーキテクチャ設計
ktatsuya
0
880
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
KATA
mclloyd
PRO
35
15k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
410
Design in an AI World
tapps
1
310
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
250
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
660
My Coaching Mixtape
mlcsv
0
310
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
Transcript
MongoDB CRUD ܱ৳ หׄ ᄎົčࡏܒaࡓ॥aСٺĎ insert db.test.insert({name: "YuanxinQiu", age: 23})
db.test.insert({name: "Kakaxi", age: 50, sex: 1}) ଏಪ҂ᆦӻਈҬೆđ҂ݖ۲۱ adapter յ๙ਔ MongoDB ଽ֥҆ਈҬೆٚمb find // 查找年龄为 23 的记录 db.users.find({age: 23}) // 查找年龄在 20 ~ 30 的记录 db.users.find({age: {$gt: 20, $lt: 30}}) // 查找年龄为 23 或 50 的记录 db.users.find({$or: [{age: 23}, {age: 50}]}) // 查找年龄⼤大于30 或 年龄⼩小于20 的记录 db.users.find({$or: [{age: {$gt: 30}}, {age: {$lt: 20} }]}) // skip limit db.users.find().skip(1).limit(10) ӈႨ֥ ֩Ⴟ, $gt, $lt, $gte, $lte, $ne ֩Ⴟ, $or, $in, $nin ߎᆦӻᆞᄵіղൔ // ⽤用户名字以 j 开头, e 结尾 db.users.find({name: /^j/, name: /e$/}) ۚࠩҰ࿘
count distinct group mapReduce update ݦඔࢤ१ db.collection.update(criteria, objNew, upsert, mult)
criteria ླေ۷ྍ֥іղൔ objNew ۷ྍіղൔ upsert ҂թᄝൈđ൞ڎҬೆ mult ൞ڎ۷ྍ؟۱໓֖ // 将年龄为 23 的⼈人,sex 改为 0 db.users.update({age: 23}, {$set: {sex: 0}}) अ҆۷ྍ ଏಪđ۷ྍൈđ൞ᆰࢤࡼ໓ู֖ߐ֥b db.users.insert({name: "YuanxinQiu", age: 23}) // => {"_id": ObjectId("5214ccc35493607a0eae4e0f"), name: "YuanxinQiu", age: 23} db.users.update({age: 23}, {name: "QiuYuanxin"}) // => {ObjectId("5214ccc35493607a0eae4e0f"), name: "QiuYuanxin"} $inc ބ $set $inc ࠧđᄹਈ۷ྍĠط $set ࠧđᆰࢤഡᇂᆴ. db.users.insert({name: "YuanxinQiu", age: 23}) // => {"_id": ObjectId("5214ccc35493607a0eae4e0f"), name: "YuanxinQiu", age: 23} db.users.update({age: 23}, {$inc: {age: 2}}) // => {"_id": ObjectId("5214ccc35493607a0eae4e0f"), name: "YuanxinQiu", age: 25} db.users.update({age: 23}, {$set: {age: 25}}) // => {"_id": ObjectId("5214ccc35493607a0eae4e0f"), name: "YuanxinQiu", age: 25} remove
// 删除某⽤用户 var id = db.users.findOne({name: "Yuanxin.Qiu"})._id db.users.remove(id) // 条件删除,T掉未成年⼈人
db.users.remove({ age: {$lt: 18} }) // 删除所有数据 db.users.remove() іܱ৳ ⼀一对多 ა 多对多 ൞๙ݖ embeded ֥ٚൔൌགྷđᆺ൞ັႵ෮҂b // One to Many db.companies.insert({name: "⼩小⽶米公司", product: [ {ObjectId: "1", name: "⼩小⽶米"}, {ObjectId: "2", name: "红⽶米", price: 23.34} ]}) // 查找某公司,他有⼀一款产品,名为 “⼩小⽶米” db.companies.find({product: {name: "⼩小⽶米"}}) // Many to Many db.students.insert({name: "⼩小⽶米"}) // => ObjectId("1") db.students.insert({name: "红⽶米"}) // => ObjectId("2") db.teachers.insert({name: "雷军", students: [ObjectId("1"), ObjectId("2")] }) // 查找某个学⽣生,他被哪些⽼老师教 t1 = db.students.findOne({name: "⼩小⽶米"}) db.teachers.find({students: t1._id}) หׄ ૫ཟ collection թԥ ଆൔሱႮ ᆦӻҰ࿘č఼ն֥Ұ࿘ეओĎ
Ⴈؽࣉᇅඔऌթԥ ሱԩෞோđၛᆦӻᄉࠩљ֥ഥ෪ྟ ... ᄎົ ᇶՖСٺ ٳோ ڬЧࠢ Mongostat MongoDBСٺٚൔ ሧਘ
1. ܲٚ໓֖ 2. ϖ฿࿐๙MongoDB ঔᅚᄇ 1. ൪तᇏݓ֥NoSQLᆭਫ਼ğՖMySQL֞MongoDB 2. MySQL vs.MongoDB ۲Ⴕ഻ڵĆ