Using MongoDB with Groovy James Williams (@ecspike) BT/Ribbit
Just as NoSQL is... <ul><ul><li>post - relational </li></ul></ul><ul><ul><li>schemaless </li></ul></ul><ul><ul><li>flexibl...
Groovy is ... <ul><ul><li>a superset of Java </li></ul></ul><ul><ul><li>open to metaprogramming </li></ul></ul><ul><ul><li...
Groovy + Mongo <ul><ul><li>Java </li></ul></ul><ul><li>BasicDBObject doc = new BasicDBObject(); </li></ul><ul><li>doc.put(...
Dynamic Finders <ul><ul><li>let you query the database as if there was a schema </li></ul></ul><ul><ul><li>build complex q...
How dynamic finders work <ul><ul><li>Groovy tries to execute the function but can't find it </li></ul></ul><ul><ul><li>It ...
Groovy + Mongo in the wild
Links <ul><ul><li>Andrill: http://andrill.org </li></ul></ul><ul><ul><li>CoreRef: http://coreref.org </li></ul></ul><ul><u...
Upcoming SlideShare
Loading in...5
×

Using MongoDB With Groovy

8,081

Published on

Lightning talk showing how to make MongoDB more Groovy

Given at NoSQL Live Boston
March 11,2010

Published in: Technology
1 Comment
1 Like
Statistics
Notes
  • For more info on Groovy metaprogramming, check out: http://www.slideshare.net/fuglylogic/mopping-up-with-groovy-presentation [PDF] http://www.grails-exchange.com/files/GraemeRocher%20-%20Keynote-DynamicGroovyMetaMagic.pdf
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
8,081
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
63
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Using MongoDB With Groovy

  1. 1. Using MongoDB with Groovy James Williams (@ecspike) BT/Ribbit
  2. 2. Just as NoSQL is... <ul><ul><li>post - relational </li></ul></ul><ul><ul><li>schemaless </li></ul></ul><ul><ul><li>flexible </li></ul></ul>
  3. 3. Groovy is ... <ul><ul><li>a superset of Java </li></ul></ul><ul><ul><li>open to metaprogramming </li></ul></ul><ul><ul><li>a more concise way to write code </li></ul></ul>
  4. 4. Groovy + Mongo <ul><ul><li>Java </li></ul></ul><ul><li>BasicDBObject doc = new BasicDBObject(); </li></ul><ul><li>doc.put(&quot;name&quot;, &quot;MongoDB&quot;); </li></ul><ul><li>doc.put(&quot;type&quot;, &quot;database&quot;); </li></ul><ul><li>doc.put(&quot;count&quot;, 1); </li></ul><ul><li>coll.insert(doc); </li></ul><ul><ul><li>Groovier </li></ul></ul><ul><li>def doc = [name:&quot;MongoDB&quot;, count:1,type:&quot;database&quot;, info: [x:203, y:102] </li></ul><ul><li>           ] as BasicDBObject </li></ul><ul><li>coll.insert(doc) </li></ul><ul><ul><li>Grooviest (using groovy-mongo) </li></ul></ul><ul><li>coll.insert([name:&quot;MongoDB&quot;, type:&quot;database&quot;, info: [x:203, y:102]]) </li></ul>
  5. 5. Dynamic Finders <ul><ul><li>let you query the database as if there was a schema </li></ul></ul><ul><ul><li>build complex query functions at runtime </li></ul></ul><ul><li>         Ex. collection.findByAuthorAndPostCreatedGreaterThan(...) </li></ul><ul><li>          collection.findByComments_CreatedOn(...) </li></ul>
  6. 6. How dynamic finders work <ul><ul><li>Groovy tries to execute the function but can't find it </li></ul></ul><ul><ul><li>It invokes methodMissing instead </li></ul></ul><ul><ul><li>The body of methodMissing takes the attempted method name and parses it </li></ul></ul><ul><ul><li>It uses the names and the modifiers (>, <, etc) with BasicDBObjectBuilder to create a prototype </li></ul></ul><ul><ul><li>It caches the created function under that name and runs it.  </li></ul></ul><ul><ul><li>Further invocations don't incur the performance hit. </li></ul></ul>
  7. 7. Groovy + Mongo in the wild
  8. 8. Links <ul><ul><li>Andrill: http://andrill.org </li></ul></ul><ul><ul><li>CoreRef: http://coreref.org </li></ul></ul><ul><ul><li>groovy-mongo: http://github.com/jwill/groovy-mongo </li></ul></ul><ul><ul><li>Personal Blog: http://jameswilliams.be/blog </li></ul></ul><ul><ul><li>Twitter: @ecspike </li></ul></ul>
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×