Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
MongoDB Basic
Search
yuanxin.qiu
August 28, 2013
Technology
82
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
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
140
Argo CDとAtlantisで実現するインフラ管理のセルフサービス化──小規模SREチームで支えるプラットフォーム
cassius7
0
270
あなたの知らないAmazon VPC Route Server/Amazon VPC Route Server you don't know about
masakiokuda
2
210
The kernel report
ennael
PRO
1
200
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
160
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
210
1万名の社員が使う認証基盤で どう信頼性を担保するか?
kairim0
0
180
行動するAIのためのオントロジー | DevRev — Encraft #26.pdf
dvrv_tknrszk
2
670
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
16
120k
OpenClawでAzure DevOpsのWiki更新を自動化する - クラウドAIだけでは届かない場所へ
yutakaosada
0
140
いちAWSエンジニアのAI活用を振り返る #devio2026 / devio osaka 2026 kawahara
masahirokawahara
2
310
メルカリにおけるAI時代の高速プロトタイピング基盤「Arca」
ryotarai
18
14k
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Code Reviewing Like a Champion
maltzj
528
40k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
For a Future-Friendly Web
brad_frost
183
10k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
How to Ace a Technical Interview
jacobian
280
24k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
66k
Optimising Largest Contentful Paint
csswizardry
37
4k
Faster Mobile Websites
deanohume
310
32k
What's in a price? How to price your products and services
michaelherold
247
13k
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 ۲Ⴕ഻ڵĆ