SlideShare a Scribd company logo
1 of 45
Download to read offline
Scala DSLs
                             Dissecting Rogue


                                           Konrad Malawski / @ktosopl
                                          GDG / PJUG / KSUG / SCKRK
                                             ScalaCamp 23.01.2012
Wednesday, December 26, 12
Wednesday, December 26, 12
Querying Mongo




Wednesday, December 26, 12
Querying Mongo




Wednesday, December 26, 12
Querying Mongo




Wednesday, December 26, 12
Querying Mongo

                             QL = Plain JSON




Wednesday, December 26, 12
Querying Mongo

                              QL = Plain JSON
                             JavaScript Console



Wednesday, December 26, 12
Querying Mongo

                              QL = Plain JSON
                             JavaScript Console
                                 Java Driver


Wednesday, December 26, 12
Querying Mongo

                  QL = Plain JSON
                 JavaScript Console
                     Java Driver
               Casbah = Scala Driver

Wednesday, December 26, 12
Querying Mongo

                  QL = Plain JSON
                 JavaScript Console
                       Java Driver
               Casbah = Scala Driver
                  ... used by Rogue
Wednesday, December 26, 12
Querying Mongo: JS



                             Console API




Wednesday, December 26, 12
Querying Mongo: JS


            db.inventory.find( {} )




Wednesday, December 26, 12
Querying Mongo: JS


            db.inventory.find( {} )



                               “find all”




Wednesday, December 26, 12
Querying Mongo: JS

            db.inventory.find(
              {
                qty: { $gt: 20 }
              }
            )




Wednesday, December 26, 12
Querying Mongo: JS

            db.inventory.find(
              {
                qty: { $gt: 20 }
              }
            )
                          gt means >=




Wednesday, December 26, 12
Querying Mongo: JS
            db.pople.find(
              {
                age: { $gte: 20 },
                $or: [
                  { name: “Ken” },
                  { name: “Kenshiro” },
                  { city: “Tokyo” },
                  ...
                ]
              }
            )




Wednesday, December 26, 12
Querying Mongo: JS
            db.pople.find(
              {
                age: { $gte: 20 },
                $or: [
                  { name: “Ken” },        $or may contain any clause
                  { name: “Kenshiro” },
                  { city: “Tokyo” },
                  ...
                ]
              }
            )




Wednesday, December 26, 12
Querying Mongo: Java


                              Java API
                             (Morhpia)




Wednesday, December 26, 12
Querying Mongo: Java


       ds.find(Employee.class).field("manager").equal(null).get();




Wednesday, December 26, 12
Querying Mongo: Java


       ds.find(Employee.class).field("manager").equal(null).get();



                                        You call this typesafe!?




Wednesday, December 26, 12
Mongo with Rogue




Wednesday, December 26, 12
Rogue in Action



               import com.foursquare.rogue.Rogue._




Wednesday, December 26, 12
Rogue in Action



               Person where(_.age gte 18) limit(100) fetch()




Wednesday, December 26, 12
Rogue in Action


                                   Code Completion
                                                           Code Completion

               Person where(_.age gte 18) limit(100) fetch()

                                                      Code Completion
                               Code Completion




Wednesday, December 26, 12
Rogue in Action



               Person where(_.age gte “Bazinga”) limit(100) fetch()




Wednesday, December 26, 12
Rogue in Action



               Person where(_.age gte “Bazinga”) limit(100) fetch()



                                       Won’t compile - age is IntField




Wednesday, December 26, 12
Rogue in Action



               Person where(_.age gte 18) limit(100) fetch()




Wednesday, December 26, 12
Rogue in Action



               Person where(_.age gte 18) limit(100) fetch()



                                               Limit




Wednesday, December 26, 12
Rogue in Action



               Person where(_.age gte 18) limit(100) foreach { p =>
                 println(”Name: ” + p.firstName)
               }




Wednesday, December 26, 12
Rogue in Action

                                     gte means >=




               Person where(_.age gte 18) limit(100) foreach { p =>
                 println(”Name: ” + p.firstName)
               }




Wednesday, December 26, 12
Rogue in Action


               Person or(
                 _.where(_.name eqs "Ken"),
                 _.where(_.name eqs "ken")
                 _.whereOpt(Option("Kenshiro")(_.name eqs _))
               ) get()




Wednesday, December 26, 12
Rogue in Action

                                   eqs means Equals


               Person or(
                 _.where(_.name eqs "Ken"),
                 _.where(_.name eqs "ken")
                 _.whereOpt(Option("Kenshiro")(_.name eqs _))
               ) get()




Wednesday, December 26, 12
Rogue in Action

                                         eqs means Equals


               Person or(
                 _.where(_.name eqs "Ken"),
                 _.where(_.name eqs "ken")
                 _.whereOpt(Option("Kenshiro")(_.name eqs _))
               ) get()



                    Get me one Person.




Wednesday, December 26, 12
Rogue in Action

                                         eqs means Equals


               Person or(
                 _.where(_.name eqs "Ken"),
                 _.where(_.name eqs "ken")
                 _.whereOpt(Option("Kenshiro")(_.name eqs _))
               ) get()
                                     Issue #69: fix in my pull req


                    Get me one Person.




Wednesday, December 26, 12
Live Hacking




Wednesday, December 26, 12
Live Hacking




Wednesday, December 26, 12
Live Hacking




Wednesday, December 26, 12
Live Hacking

                             Advanced Stuff.




Wednesday, December 26, 12
Live Hacking

                             Advanced Stuff.
                                 Fast.



Wednesday, December 26, 12
Live Hacking

                             Advanced Stuff.
                                 Fast.
                             Ask Questions!

Wednesday, December 26, 12
Wednesday, December 26, 12
def links =
                       • Scala Lang http://www.scala-lang.org/
                       • Scala Koans http://www.scalakoans.org
                       • Blog.Project13.pl - http://www.blog.project13.pl
                       •MongoDB ref - docs.mongodb.org/manual/reference/operators/
                       • Foursquare Rogue - https://github.com/foursquare/rogue
                       • Java Morphia - http://code.google.com/p/morphia/
                       • Kraków Scala UG - http://krakowscala.pl / http://scalacamp.pl




Wednesday, December 26, 12
def links =
                       • Scala Lang http://www.scala-lang.org/
                       • Scala Koans http://www.scalakoans.org
                       • Blog.Project13.pl - http://www.blog.project13.pl
                       •MongoDB ref - docs.mongodb.org/manual/reference/operators/
                       • Foursquare Rogue - https://github.com/foursquare/rogue
                       • Java Morphia - http://code.google.com/p/morphia/
                       • Kraków Scala UG - http://krakowscala.pl / http://scalacamp.pl




                                                                 Mailing lists rock!



Wednesday, December 26, 12
Thanks!
                              Dziękuję!
                             ありがとう!




                                           Konrad Malawski / @ktosopl
                                          GDG / PJUG / KSUG / SCKRK
                                             ScalaCamp 23.01.2012
Wednesday, December 26, 12
Thanks!
                                               Dziękuję!
                                              ありがとう!




                        I love feedback! <3                 Konrad Malawski / @ktosopl
                                                           GDG / PJUG / KSUG / SCKRK
                                                              ScalaCamp 23.01.2012
Wednesday, December 26, 12

More Related Content

What's hot

Html5 game programming overview
Html5 game programming overviewHtml5 game programming overview
Html5 game programming overview
민태 김
 
Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构
Tommy Chiu
 

What's hot (9)

Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data Visualisation
 
Heroku Postgres Cloud Database Webinar
Heroku Postgres Cloud Database WebinarHeroku Postgres Cloud Database Webinar
Heroku Postgres Cloud Database Webinar
 
Html5 game programming overview
Html5 game programming overviewHtml5 game programming overview
Html5 game programming overview
 
Modern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter BootstrapModern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter Bootstrap
 
MongoDB With Style
MongoDB With StyleMongoDB With Style
MongoDB With Style
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构
 
Big Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 MinutesBig Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 Minutes
 
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
 

Viewers also liked

Ebay legacy-code-retreat
Ebay legacy-code-retreatEbay legacy-code-retreat
Ebay legacy-code-retreat
Konrad Malawski
 
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsFresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Konrad Malawski
 

Viewers also liked (20)

Android at-xsolve
Android at-xsolveAndroid at-xsolve
Android at-xsolve
 
Git tak po prostu (SFI version)
Git tak po prostu (SFI version)Git tak po prostu (SFI version)
Git tak po prostu (SFI version)
 
TDD drogą do oświecenia w Scali
TDD drogą do oświecenia w ScaliTDD drogą do oświecenia w Scali
TDD drogą do oświecenia w Scali
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good Parts
 
Open soucerers - jak zacząć swoją przygodę z open source
Open soucerers - jak zacząć swoją przygodę z open sourceOpen soucerers - jak zacząć swoją przygodę z open source
Open soucerers - jak zacząć swoją przygodę z open source
 
Android my Scala @ JFokus 2013
Android my Scala @ JFokus 2013Android my Scala @ JFokus 2013
Android my Scala @ JFokus 2013
 
HBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceHBase RowKey design for Akka Persistence
HBase RowKey design for Akka Persistence
 
Scalding - the not-so-basics @ ScalaDays 2014
Scalding - the not-so-basics @ ScalaDays 2014Scalding - the not-so-basics @ ScalaDays 2014
Scalding - the not-so-basics @ ScalaDays 2014
 
Ebay legacy-code-retreat
Ebay legacy-code-retreatEbay legacy-code-retreat
Ebay legacy-code-retreat
 
Need for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applicationsNeed for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applications
 
KrakDroid: Scala on Android
KrakDroid: Scala on AndroidKrakDroid: Scala on Android
KrakDroid: Scala on Android
 
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
 
Scalding - Hadoop Word Count in LESS than 70 lines of code
Scalding - Hadoop Word Count in LESS than 70 lines of codeScalding - Hadoop Word Count in LESS than 70 lines of code
Scalding - Hadoop Word Count in LESS than 70 lines of code
 
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
 
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsFresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
 
Disrupt 2 Grow - Devoxx 2013
Disrupt 2 Grow - Devoxx 2013Disrupt 2 Grow - Devoxx 2013
Disrupt 2 Grow - Devoxx 2013
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
 
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
 
The Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldThe Need for Async @ ScalaWorld
The Need for Async @ ScalaWorld
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016
 

More from Konrad Malawski

Reactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsReactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka Streams
Konrad Malawski
 

More from Konrad Malawski (19)

Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018
 
Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018
 
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
 
State of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to comeState of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to come
 
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCBuilding a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
 
Akka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming WorldAkka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming World
 
Reactive integrations with Akka Streams
Reactive integrations with Akka StreamsReactive integrations with Akka Streams
Reactive integrations with Akka Streams
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabs
 
Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!Reactive Streams, j.u.concurrent & Beyond!
Reactive Streams, j.u.concurrent & Beyond!
 
End to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to SocketEnd to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to Socket
 
The Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneThe Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOne
 
Krakow communities @ 2016
Krakow communities @ 2016Krakow communities @ 2016
Krakow communities @ 2016
 
Zen of Akka
Zen of AkkaZen of Akka
Zen of Akka
 
How Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemHow Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM Ecosystem
 
Reactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsReactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka Streams
 
Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014
 
2014 akka-streams-tokyo-japanese
2014 akka-streams-tokyo-japanese2014 akka-streams-tokyo-japanese
2014 akka-streams-tokyo-japanese
 
Distributed Consensus A.K.A. "What do we eat for lunch?"
Distributed Consensus A.K.A. "What do we eat for lunch?"Distributed Consensus A.K.A. "What do we eat for lunch?"
Distributed Consensus A.K.A. "What do we eat for lunch?"
 
DDDing Tools = Akka Persistence
DDDing Tools = Akka PersistenceDDDing Tools = Akka Persistence
DDDing Tools = Akka Persistence
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Scala dsls-dissecting-and-implementing-rogue

  • 1. Scala DSLs Dissecting Rogue Konrad Malawski / @ktosopl GDG / PJUG / KSUG / SCKRK ScalaCamp 23.01.2012 Wednesday, December 26, 12
  • 6. Querying Mongo QL = Plain JSON Wednesday, December 26, 12
  • 7. Querying Mongo QL = Plain JSON JavaScript Console Wednesday, December 26, 12
  • 8. Querying Mongo QL = Plain JSON JavaScript Console Java Driver Wednesday, December 26, 12
  • 9. Querying Mongo QL = Plain JSON JavaScript Console Java Driver Casbah = Scala Driver Wednesday, December 26, 12
  • 10. Querying Mongo QL = Plain JSON JavaScript Console Java Driver Casbah = Scala Driver ... used by Rogue Wednesday, December 26, 12
  • 11. Querying Mongo: JS Console API Wednesday, December 26, 12
  • 12. Querying Mongo: JS db.inventory.find( {} ) Wednesday, December 26, 12
  • 13. Querying Mongo: JS db.inventory.find( {} ) “find all” Wednesday, December 26, 12
  • 14. Querying Mongo: JS db.inventory.find( { qty: { $gt: 20 } } ) Wednesday, December 26, 12
  • 15. Querying Mongo: JS db.inventory.find( { qty: { $gt: 20 } } ) gt means >= Wednesday, December 26, 12
  • 16. Querying Mongo: JS db.pople.find( { age: { $gte: 20 }, $or: [ { name: “Ken” }, { name: “Kenshiro” }, { city: “Tokyo” }, ... ] } ) Wednesday, December 26, 12
  • 17. Querying Mongo: JS db.pople.find( { age: { $gte: 20 }, $or: [ { name: “Ken” }, $or may contain any clause { name: “Kenshiro” }, { city: “Tokyo” }, ... ] } ) Wednesday, December 26, 12
  • 18. Querying Mongo: Java Java API (Morhpia) Wednesday, December 26, 12
  • 19. Querying Mongo: Java ds.find(Employee.class).field("manager").equal(null).get(); Wednesday, December 26, 12
  • 20. Querying Mongo: Java ds.find(Employee.class).field("manager").equal(null).get(); You call this typesafe!? Wednesday, December 26, 12
  • 21. Mongo with Rogue Wednesday, December 26, 12
  • 22. Rogue in Action import com.foursquare.rogue.Rogue._ Wednesday, December 26, 12
  • 23. Rogue in Action Person where(_.age gte 18) limit(100) fetch() Wednesday, December 26, 12
  • 24. Rogue in Action Code Completion Code Completion Person where(_.age gte 18) limit(100) fetch() Code Completion Code Completion Wednesday, December 26, 12
  • 25. Rogue in Action Person where(_.age gte “Bazinga”) limit(100) fetch() Wednesday, December 26, 12
  • 26. Rogue in Action Person where(_.age gte “Bazinga”) limit(100) fetch() Won’t compile - age is IntField Wednesday, December 26, 12
  • 27. Rogue in Action Person where(_.age gte 18) limit(100) fetch() Wednesday, December 26, 12
  • 28. Rogue in Action Person where(_.age gte 18) limit(100) fetch() Limit Wednesday, December 26, 12
  • 29. Rogue in Action Person where(_.age gte 18) limit(100) foreach { p => println(”Name: ” + p.firstName) } Wednesday, December 26, 12
  • 30. Rogue in Action gte means >= Person where(_.age gte 18) limit(100) foreach { p => println(”Name: ” + p.firstName) } Wednesday, December 26, 12
  • 31. Rogue in Action Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get() Wednesday, December 26, 12
  • 32. Rogue in Action eqs means Equals Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get() Wednesday, December 26, 12
  • 33. Rogue in Action eqs means Equals Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get() Get me one Person. Wednesday, December 26, 12
  • 34. Rogue in Action eqs means Equals Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get() Issue #69: fix in my pull req Get me one Person. Wednesday, December 26, 12
  • 38. Live Hacking Advanced Stuff. Wednesday, December 26, 12
  • 39. Live Hacking Advanced Stuff. Fast. Wednesday, December 26, 12
  • 40. Live Hacking Advanced Stuff. Fast. Ask Questions! Wednesday, December 26, 12
  • 42. def links = • Scala Lang http://www.scala-lang.org/ • Scala Koans http://www.scalakoans.org • Blog.Project13.pl - http://www.blog.project13.pl •MongoDB ref - docs.mongodb.org/manual/reference/operators/ • Foursquare Rogue - https://github.com/foursquare/rogue • Java Morphia - http://code.google.com/p/morphia/ • Kraków Scala UG - http://krakowscala.pl / http://scalacamp.pl Wednesday, December 26, 12
  • 43. def links = • Scala Lang http://www.scala-lang.org/ • Scala Koans http://www.scalakoans.org • Blog.Project13.pl - http://www.blog.project13.pl •MongoDB ref - docs.mongodb.org/manual/reference/operators/ • Foursquare Rogue - https://github.com/foursquare/rogue • Java Morphia - http://code.google.com/p/morphia/ • Kraków Scala UG - http://krakowscala.pl / http://scalacamp.pl Mailing lists rock! Wednesday, December 26, 12
  • 44. Thanks! Dziękuję! ありがとう! Konrad Malawski / @ktosopl GDG / PJUG / KSUG / SCKRK ScalaCamp 23.01.2012 Wednesday, December 26, 12
  • 45. Thanks! Dziękuję! ありがとう! I love feedback! <3 Konrad Malawski / @ktosopl GDG / PJUG / KSUG / SCKRK ScalaCamp 23.01.2012 Wednesday, December 26, 12