進階使用Nodejs-淺談
NoSQL(MongoDB)
MiCloud Team Benson
什麼是NoSQL
Big User
什麼是NoSQL
Big Data
什麼是NoSQL
五大特性
● Not Only SQL
● 水平擴充資料庫容量
● No Schema
● 資料遲早一致
● 新技術成熟度不足,版本風險
NoSQL的種類與特性
NoSQL的種類與特性
About Mongo DB
●
●
●
●

Open Source
Document database
Written in C++
Bson
mongoDB VS SQL
Database == Database
Collections == Table
Document == Row
實作Nodejs and MongoDB
安裝Mongodb
範例程式
http://goo.gl/SbvZPx
程式實作Create document
● npm install mongodb
var doc1 = {'hello':'doc1'};
var doc2 = {'hello':'doc2'};
var lotsOfDocs = [{'he...
程式實作Query document
//查詢全部
collection.find().toArray(function(err, items) {})
//除了2以外
var stream = collection.find({mykey:{...
程式實作update document
collection.update({mykey:1}, {$set:{fieldtoupdate:2}}, {w:1}, function
(err, result) {});
collection.u...
程式實作Delete Document
//刪除單一筆
collection.remove({mykey:1});
//刪除單一筆並傳回結果
collection.remove({mykey:2}, {w:1}, function(err, r...
Map-Reduce
什麼是 Map
● Function
● 平行獨立,不影響原 Collection
MAP

Collection

[{key: value},
{key: value},
{key: value}]
Map-Reduce
Map-Reduce
什麼是Reduce
Map-Reduce
NoSQL知名案例
●
●
●
●

Facebook (Cassandra , HBase)
Twitter (Cassandra, HBase)
Yahoo(HBase)
力可科技(Cassandra)
其他資源
● MongoHQ http://www.mongohq.com/home
● mongoDB
http://www.mongodb.org/
謝謝大家
Upcoming SlideShare
Loading in …5
×

進階使用Nodejs 淺談no sql(mongodb)

2,094 views

Published on

Node.js with MongoDB in action...

Published in: Technology, Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,094
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
20
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

進階使用Nodejs 淺談no sql(mongodb)

  1. 1. 進階使用Nodejs-淺談 NoSQL(MongoDB) MiCloud Team Benson
  2. 2. 什麼是NoSQL Big User
  3. 3. 什麼是NoSQL Big Data
  4. 4. 什麼是NoSQL 五大特性 ● Not Only SQL ● 水平擴充資料庫容量 ● No Schema ● 資料遲早一致 ● 新技術成熟度不足,版本風險
  5. 5. NoSQL的種類與特性
  6. 6. NoSQL的種類與特性
  7. 7. About Mongo DB ● ● ● ● Open Source Document database Written in C++ Bson
  8. 8. mongoDB VS SQL Database == Database Collections == Table Document == Row
  9. 9. 實作Nodejs and MongoDB 安裝Mongodb
  10. 10. 範例程式 http://goo.gl/SbvZPx
  11. 11. 程式實作Create document ● npm install mongodb var doc1 = {'hello':'doc1'}; var doc2 = {'hello':'doc2'}; var lotsOfDocs = [{'hello':'doc3'}, {'hello':'doc4'}]; collection.insert(doc1); collection.insert(doc2, {w:1}, function(err, result) {}); collection.insert(lotsOfDocs, {w:1}, function(err, result) {});
  12. 12. 程式實作Query document //查詢全部 collection.find().toArray(function(err, items) {}) //除了2以外 var stream = collection.find({mykey:{$ne:2}}).stream(); stream.on("data", function(item) {}); stream.on("end", function() {}); //單一筆 collection.findOne({mykey:1}, function(err, item) {});
  13. 13. 程式實作update document collection.update({mykey:1}, {$set:{fieldtoupdate:2}}, {w:1}, function (err, result) {}); collection.update({mykey:2}, {$push:{docs:{doc2:1}}}, {w:1}, function (err, result) {});
  14. 14. 程式實作Delete Document //刪除單一筆 collection.remove({mykey:1}); //刪除單一筆並傳回結果 collection.remove({mykey:2}, {w:1}, function(err, result) {}); //刪除全部 collection.remove();
  15. 15. Map-Reduce 什麼是 Map ● Function ● 平行獨立,不影響原 Collection MAP Collection [{key: value}, {key: value}, {key: value}]
  16. 16. Map-Reduce
  17. 17. Map-Reduce 什麼是Reduce
  18. 18. Map-Reduce
  19. 19. NoSQL知名案例 ● ● ● ● Facebook (Cassandra , HBase) Twitter (Cassandra, HBase) Yahoo(HBase) 力可科技(Cassandra)
  20. 20. 其他資源 ● MongoHQ http://www.mongohq.com/home ● mongoDB http://www.mongodb.org/
  21. 21. 謝謝大家

×