SlideShare a Scribd company logo
1 of 25
Download to read offline
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB




                                         HTTP
                                       WebSocket




     Client (Flash)                       LB

                                                    node.js
                                                                             3x3 Sharding
                                                                              MongoDB



                                                               Content
                                                   SVN or git Distribution
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB



                        var entity = {
                          _id: ‘abc’,
                          name: ‘test’,
                          body: {
                            parts: {
                              face: 0, eye: 2, nose: 4, mouth: 2
                            },
                            colors: {
                               skin: 1, eye: 4, hair: 3
                            }
                          }
                        };

                        col.save(entity);

                        col.findOne({_id:‘abc’}, function(err, result) {
                            console.log(result.body.parts);
                        });

                        col.update({_id:‘abc’},
                          {‘$set’, {name: ‘modified’}}
                        );
Mongo Tokyo 2011 - node.js + MongoDB




                        https://github.com/orlandov/node-mongodb/




                        https://github.com/christkv/node-mongodb-native/
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB




                var client = new Db('test', new Server("127.0.0.1", 27017, {}));
                client.open(function(err, p_client) {
                  client.createCollection('test_insert',function(err, collection) {
                    client.collection('test_insert', function(err, collection) {
                      for(var i = 1; i < 1000; i++) {
                        collection.insert({c:1}, function(err, docs) {});
                      }
                      collection.insert({a:2}, function(err, docs) {
                        collection.insert({a:3}, function(err, docs) {
                          collection.count(function(err, count) {
                            test.assertEquals(1001, count);
                            collection.find(function(err, cursor) {
                              cursor.toArray(function(err, results) {
                                test.assertEquals(1001, results.length);
                                test.assertTrue(results[0] != null);
                                client.close();
                              });
                            });
                          });
                        });
                      });
                    });
                  });
                });
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB




                var db = new Database(‘127.0.0.1’, 3306, ‘test’);
                db.open();

                var item = db.collection(‘item’);

                item
                  .begin()
                  .insert({_id:‘test’, name:‘abcdefg’})
                  .insert({_id:‘test2’, name:‘123456’, values:[0,1,2,3]);
                  .update({_id:‘test’}, {‘$set’: { name: ‘hijklmn’ })
                  .find({}).each(function(entity) {
                     console.log(entity.name);
                  })
                  .success(function() {
                     console.log(‘done’);
                  })
                  .failure(function(err) {
                     console.log(‘error’, err);
                  })
                  .end();
Mongo Tokyo 2011 - node.js + MongoDB




                        https://github.com/LearnBoost/mongoose
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB




                var spec1 = {
                   name: ‘test’,
                   type: ‘text’,
                   label: ‘label-1’,
                   class: ‘number’,
                   min: 0, max: 100
                };

                var spec2 = {
                   name: ‘test2’,
                   type: ‘group’,
                   label: ‘group-1’,
                   fields: [spec3, spec4, spec5]
                };

                var formSpec = [
                   spec1, spec2
                ];

                showForm(formSpec);
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB
Mongo Tokyo 2011 - node.js + MongoDB

                                 { "_id" : "plant_ichigo",

                                       "name" : "    ",
                                       "type" : "plant",
                                       "plant" : {
                                         "tags" : [ "vegetable" ],
                                         "time" : { "grow" : 10, "expire" : 60 },
                                         "rewards" : [
                                 !       {
                                 !       !    "type" : "coin",
                                 !       !    "rate" : 1,
                                 !       !    "min" : 5,
                                 !       !    "max" : 20,
                                 !       !    "code" : ""
                                 !       },
                                 !       {
                                 !       !    "type" : "exp",
                                 !       !    "rate" : 1,
                                 !       !    "min" : 1,
                                 !       !    "max" : 2,
                                 !       !    "code" : ""
                                 !       },
                                 !       {
                                 !       !    "type" : "item",
                                 !       !    "rate" : 1,
                                 !       !    "min" : 1,
                                 !       !    "max" : 1,
                                 !       !    "code" : "material_ichigo"
                                 !       }
                                 ]}
Mongo Tokyo 2011 - node.js + MongoDB

More Related Content

What's hot

FrozenRails Training
FrozenRails TrainingFrozenRails Training
FrozenRails Training
Mike Dirolf
 
Social Analytics with MongoDB
Social Analytics with MongoDBSocial Analytics with MongoDB
Social Analytics with MongoDB
Patrick Stokes
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
Ryousei Takano
 

What's hot (20)

Node.js Stream API
Node.js Stream APINode.js Stream API
Node.js Stream API
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Supercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicSupercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamic
 
Couchdb w Ruby'm
Couchdb w Ruby'mCouchdb w Ruby'm
Couchdb w Ruby'm
 
Metaprogramming with JavaScript
Metaprogramming with JavaScriptMetaprogramming with JavaScript
Metaprogramming with JavaScript
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDB
 
2011 09-pdfjs
2011 09-pdfjs2011 09-pdfjs
2011 09-pdfjs
 
FrozenRails Training
FrozenRails TrainingFrozenRails Training
FrozenRails Training
 
20110514 mongo dbチューニング
20110514 mongo dbチューニング20110514 mongo dbチューニング
20110514 mongo dbチューニング
 
Interactive subway map
Interactive subway mapInteractive subway map
Interactive subway map
 
Social Analytics with MongoDB
Social Analytics with MongoDBSocial Analytics with MongoDB
Social Analytics with MongoDB
 
MongoDB - Monitoring & queueing
MongoDB - Monitoring & queueingMongoDB - Monitoring & queueing
MongoDB - Monitoring & queueing
 
Understanding the Node.js Platform
Understanding the Node.js PlatformUnderstanding the Node.js Platform
Understanding the Node.js Platform
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
 
How to build microservices with node.js
How to build microservices with node.jsHow to build microservices with node.js
How to build microservices with node.js
 

Viewers also liked

[大図解]ピグライフはこう動いている
[大図解]ピグライフはこう動いている[大図解]ピグライフはこう動いている
[大図解]ピグライフはこう動いている
Akihiro Kuwano
 

Viewers also liked (20)

[大図解]ピグライフはこう動いている
[大図解]ピグライフはこう動いている[大図解]ピグライフはこう動いている
[大図解]ピグライフはこう動いている
 
Node.js を選ぶとき 選ばないとき
Node.js を選ぶとき 選ばないときNode.js を選ぶとき 選ばないとき
Node.js を選ぶとき 選ばないとき
 
Node.js入門
Node.js入門Node.js入門
Node.js入門
 
Node.js×mongo dbで3年間サービス運用してみた話
Node.js×mongo dbで3年間サービス運用してみた話Node.js×mongo dbで3年間サービス運用してみた話
Node.js×mongo dbで3年間サービス運用してみた話
 
Node.js基礎の基礎 - Miyazaki.js vol.2
Node.js基礎の基礎 - Miyazaki.js vol.2Node.js基礎の基礎 - Miyazaki.js vol.2
Node.js基礎の基礎 - Miyazaki.js vol.2
 
しごとで使うTitanium 第2版
しごとで使うTitanium 第2版しごとで使うTitanium 第2版
しごとで使うTitanium 第2版
 
Node js 入門
Node js 入門Node js 入門
Node js 入門
 
Nodeについて
NodeについてNodeについて
Nodeについて
 
イベント駆動プログラミングとI/O多重化
イベント駆動プログラミングとI/O多重化イベント駆動プログラミングとI/O多重化
イベント駆動プログラミングとI/O多重化
 
Japan 2011: Dreams will never die & Ganbaro Nippon
Japan 2011: Dreams will never die & Ganbaro Nippon Japan 2011: Dreams will never die & Ganbaro Nippon
Japan 2011: Dreams will never die & Ganbaro Nippon
 
Shinjuku.rb 20151125 PayPal 101
Shinjuku.rb 20151125 PayPal 101Shinjuku.rb 20151125 PayPal 101
Shinjuku.rb 20151125 PayPal 101
 
コンポーネント単位で考えるWeb制作
コンポーネント単位で考えるWeb制作コンポーネント単位で考えるWeb制作
コンポーネント単位で考えるWeb制作
 
パーフェクト"Elixir情報収集"
パーフェクト"Elixir情報収集"パーフェクト"Elixir情報収集"
パーフェクト"Elixir情報収集"
 
API Meetup #8 PayPal API
API Meetup #8 PayPal APIAPI Meetup #8 PayPal API
API Meetup #8 PayPal API
 
Node.js Tutorial at Hiroshima
Node.js Tutorial at HiroshimaNode.js Tutorial at Hiroshima
Node.js Tutorial at Hiroshima
 
TypeScriptへの入口
TypeScriptへの入口TypeScriptへの入口
TypeScriptへの入口
 
新入社員のための大規模ゲーム開発入門 サーバサイド編
新入社員のための大規模ゲーム開発入門 サーバサイド編新入社員のための大規模ゲーム開発入門 サーバサイド編
新入社員のための大規模ゲーム開発入門 サーバサイド編
 
大規模ソーシャルゲーム開発から学んだPHP&MySQL実践テクニック
大規模ソーシャルゲーム開発から学んだPHP&MySQL実践テクニック大規模ソーシャルゲーム開発から学んだPHP&MySQL実践テクニック
大規模ソーシャルゲーム開発から学んだPHP&MySQL実践テクニック
 
大規模ソーシャルゲームを支える技術~PHP+MySQLを使った高負荷対策~
大規模ソーシャルゲームを支える技術~PHP+MySQLを使った高負荷対策~大規模ソーシャルゲームを支える技術~PHP+MySQLを使った高負荷対策~
大規模ソーシャルゲームを支える技術~PHP+MySQLを使った高負荷対策~
 
CEDEC2013 ソーシャルゲームの開発現場でUXについて思いっきりあがいてみた1年間の話
CEDEC2013 ソーシャルゲームの開発現場でUXについて思いっきりあがいてみた1年間の話CEDEC2013 ソーシャルゲームの開発現場でUXについて思いっきりあがいてみた1年間の話
CEDEC2013 ソーシャルゲームの開発現場でUXについて思いっきりあがいてみた1年間の話
 

Similar to MongoDB + node.js で作るソーシャルゲーム

みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
techtalkdwango
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
Takuya Fujimura
 
HadoopとMongoDBを活用したソーシャルアプリのログ解析
HadoopとMongoDBを活用したソーシャルアプリのログ解析HadoopとMongoDBを活用したソーシャルアプリのログ解析
HadoopとMongoDBを活用したソーシャルアプリのログ解析
Takahiro Inoue
 
Mongo db勉強会20110730
Mongo db勉強会20110730Mongo db勉強会20110730
Mongo db勉強会20110730
Akihiro Okuno
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
Marc s01 e02-crud-database
Marc s01 e02-crud-databaseMarc s01 e02-crud-database
Marc s01 e02-crud-database
MongoDB
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
MongoDB
 

Similar to MongoDB + node.js で作るソーシャルゲーム (20)

ActiveRecord vs Mongoid
ActiveRecord vs MongoidActiveRecord vs Mongoid
ActiveRecord vs Mongoid
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live Hacking
 
Mongoskin - Guilin
Mongoskin - GuilinMongoskin - Guilin
Mongoskin - Guilin
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへ
 
HadoopとMongoDBを活用したソーシャルアプリのログ解析
HadoopとMongoDBを活用したソーシャルアプリのログ解析HadoopとMongoDBを活用したソーシャルアプリのログ解析
HadoopとMongoDBを活用したソーシャルアプリのログ解析
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
 
Mongo db勉強会20110730
Mongo db勉強会20110730Mongo db勉強会20110730
Mongo db勉強会20110730
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
Marc s01 e02-crud-database
Marc s01 e02-crud-databaseMarc s01 e02-crud-database
Marc s01 e02-crud-database
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
 
Latinoware
LatinowareLatinoware
Latinoware
 
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 

MongoDB + node.js で作るソーシャルゲーム

  • 1.
  • 2. Mongo Tokyo 2011 - node.js + MongoDB
  • 3. Mongo Tokyo 2011 - node.js + MongoDB
  • 4. Mongo Tokyo 2011 - node.js + MongoDB
  • 5. Mongo Tokyo 2011 - node.js + MongoDB
  • 6. Mongo Tokyo 2011 - node.js + MongoDB
  • 7. Mongo Tokyo 2011 - node.js + MongoDB
  • 8. Mongo Tokyo 2011 - node.js + MongoDB
  • 9. Mongo Tokyo 2011 - node.js + MongoDB HTTP WebSocket Client (Flash) LB node.js 3x3 Sharding MongoDB Content SVN or git Distribution
  • 10. Mongo Tokyo 2011 - node.js + MongoDB
  • 11. Mongo Tokyo 2011 - node.js + MongoDB var entity = { _id: ‘abc’, name: ‘test’, body: { parts: { face: 0, eye: 2, nose: 4, mouth: 2 }, colors: { skin: 1, eye: 4, hair: 3 } } }; col.save(entity); col.findOne({_id:‘abc’}, function(err, result) { console.log(result.body.parts); }); col.update({_id:‘abc’}, {‘$set’, {name: ‘modified’}} );
  • 12. Mongo Tokyo 2011 - node.js + MongoDB https://github.com/orlandov/node-mongodb/ https://github.com/christkv/node-mongodb-native/
  • 13. Mongo Tokyo 2011 - node.js + MongoDB
  • 14. Mongo Tokyo 2011 - node.js + MongoDB var client = new Db('test', new Server("127.0.0.1", 27017, {})); client.open(function(err, p_client) { client.createCollection('test_insert',function(err, collection) { client.collection('test_insert', function(err, collection) { for(var i = 1; i < 1000; i++) { collection.insert({c:1}, function(err, docs) {}); } collection.insert({a:2}, function(err, docs) { collection.insert({a:3}, function(err, docs) { collection.count(function(err, count) { test.assertEquals(1001, count); collection.find(function(err, cursor) { cursor.toArray(function(err, results) { test.assertEquals(1001, results.length); test.assertTrue(results[0] != null); client.close(); }); }); }); }); }); }); }); });
  • 15. Mongo Tokyo 2011 - node.js + MongoDB
  • 16. Mongo Tokyo 2011 - node.js + MongoDB var db = new Database(‘127.0.0.1’, 3306, ‘test’); db.open(); var item = db.collection(‘item’); item .begin() .insert({_id:‘test’, name:‘abcdefg’}) .insert({_id:‘test2’, name:‘123456’, values:[0,1,2,3]); .update({_id:‘test’}, {‘$set’: { name: ‘hijklmn’ }) .find({}).each(function(entity) { console.log(entity.name); }) .success(function() { console.log(‘done’); }) .failure(function(err) { console.log(‘error’, err); }) .end();
  • 17. Mongo Tokyo 2011 - node.js + MongoDB https://github.com/LearnBoost/mongoose
  • 18. Mongo Tokyo 2011 - node.js + MongoDB
  • 19. Mongo Tokyo 2011 - node.js + MongoDB
  • 20. Mongo Tokyo 2011 - node.js + MongoDB
  • 21. Mongo Tokyo 2011 - node.js + MongoDB var spec1 = { name: ‘test’, type: ‘text’, label: ‘label-1’, class: ‘number’, min: 0, max: 100 }; var spec2 = { name: ‘test2’, type: ‘group’, label: ‘group-1’, fields: [spec3, spec4, spec5] }; var formSpec = [ spec1, spec2 ]; showForm(formSpec);
  • 22. Mongo Tokyo 2011 - node.js + MongoDB
  • 23. Mongo Tokyo 2011 - node.js + MongoDB
  • 24. Mongo Tokyo 2011 - node.js + MongoDB { "_id" : "plant_ichigo", "name" : " ", "type" : "plant", "plant" : { "tags" : [ "vegetable" ], "time" : { "grow" : 10, "expire" : 60 }, "rewards" : [ ! { ! ! "type" : "coin", ! ! "rate" : 1, ! ! "min" : 5, ! ! "max" : 20, ! ! "code" : "" ! }, ! { ! ! "type" : "exp", ! ! "rate" : 1, ! ! "min" : 1, ! ! "max" : 2, ! ! "code" : "" ! }, ! { ! ! "type" : "item", ! ! "rate" : 1, ! ! "min" : 1, ! ! "max" : 1, ! ! "code" : "material_ichigo" ! } ]}
  • 25. Mongo Tokyo 2011 - node.js + MongoDB