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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

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