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
Webとヘルスデータ
yukukotani
1
200
Nav2、Nav3 ... はたまた自作?〜 作って理解する Nav3 の設計意図 〜 / Nav2, Nav3 ... or Build Your Own? — Understanding Nav3's design intent by building it from scratch
yanzm
0
260
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
2
460
AIで実装は速くなった。なのにプロダクトは速くならない。職能の壁を越えて価値のフローを設計する
nwiizo
7
7.4k
KPIだけでは評価できないプロダクトが考えるべき Evalsという第二の評価系 / Beyond KPIs: Evals as a Second Evaluation Framework for Products #PdEConf
aki_iinuma
4
3.7k
GoにおけるFFIのこれまでとこれから
goccy
1
550
AIエージェントの開発・提供におけるセキュリティリスクの論点と対策
flatt_security
2
600
2026-09-10 【Snowflake World Tour Tokyo 2026】dbt Core と Snowflake で実現する多層的なデータガバナンス / Multi-Layered Data Governance Powered by dbt Core and Snowflake
civitaspo
0
180
多層防御と最⼩権限で実現する、安全なAIエージェント設計パターン
lycorptech_jp
PRO
0
210
動画配信アプリでの Engage SDK 導入 — TVer Android が Play ストアにコンテンツを届けるまで
techtver
PRO
0
140
Bet AI Day 2026丨AIによって本質に戻るシステムリスク管理
layerx
PRO
0
1.3k
Backstageでつくるセルフサービスな社内開発基盤
kikunosuke75
1
360
Featured
See All Featured
A Soul's Torment
seathinner
7
3.6k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
270
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
330
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
GitHub's CSS Performance
jonrohan
1033
470k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
720
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
430
Scaling GitHub
holman
464
140k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Building Applications with DynamoDB
mza
96
7.2k
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 ۲Ⴕ഻ڵĆ