SlideShare a Scribd company logo
Building Your App:
    Perl & MongoDB
    Mike Friedman (friedo)
    Perl Engineer & Evangelist, 10gen
    http://friedo.com


    Perl Oasis 2013


Thursday, January 17, 13
10gen, the MongoDB Company




               http://www.10gen.com   http://www.mongodb.org




Thursday, January 17, 13
What is MongoDB?




Thursday, January 17, 13
What is MongoDB?


    ✤    Document Oriented Database




Thursday, January 17, 13
What is MongoDB?


    ✤    Document Oriented Database

    ✤    Open Source




Thursday, January 17, 13
What is MongoDB?


    ✤    Document Oriented Database

    ✤    Open Source

    ✤    High Performance




Thursday, January 17, 13
What is MongoDB?


    ✤    Document Oriented Database

    ✤    Open Source

    ✤    High Performance

    ✤    Horizontally Scalable




Thursday, January 17, 13
What is MongoDB?


    ✤    Document Oriented Database

    ✤    Open Source

    ✤    High Performance

    ✤    Horizontally Scalable

    ✤    Full Featured



Thursday, January 17, 13
What We Will Build:


    ✤    “Library” - A demo application

          ✤    Users

          ✤    Books

          ✤    Authors

          ✤    Publishers



Thursday, January 17, 13
What We Will Need:




Thursday, January 17, 13
What We Will Need:


    ✤    MongoDB

          ✤    http://www.mongodb.org/downloads




Thursday, January 17, 13
What We Will Need:


    ✤    MongoDB

          ✤    http://www.mongodb.org/downloads

    ✤    CPAN Modules:

          ✤    https://metacpan.org/module/Mojolicious::Lite

          ✤    https://metacpan.org/module/MongoDB



Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution


    ✤    MongoDB::MongoClient




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution


    ✤    MongoDB::MongoClient

          ✤    new in version 0.502.




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution


    ✤    MongoDB::MongoClient

          ✤    new in version 0.502.

          ✤    “Safe” (write-acknowledged) by default




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution


    ✤    MongoDB::MongoClient

          ✤    new in version 0.502.

          ✤    “Safe” (write-acknowledged) by default

          ✤    Encapsulates connection and server info




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution

    ✤    MongoDB::Database

          ✤    Represents a database (namespace) on the MongoDB server




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution

    ✤    MongoDB::Database

          ✤    Represents a database (namespace) on the MongoDB server

    ✤    MongoDB::Collection

          ✤    Represents a collection (table? kinda) in a database




Thursday, January 17, 13
Inside the MongoDB CPAN
    Distribution

    ✤    MongoDB::Database

          ✤    Represents a database (namespace) on the MongoDB server

    ✤    MongoDB::Collection

          ✤    Represents a collection (table? kinda) in a database

    ✤    MongoDB::Cursor

          ✤    Retrieves documents (rows? kinda) from a collection


Thursday, January 17, 13
MongoDB Documents




Thursday, January 17, 13
MongoDB Documents

    ✤    Documents live in Collections




Thursday, January 17, 13
MongoDB Documents

    ✤    Documents live in Collections

    ✤    Documents have no pre-defined schema




Thursday, January 17, 13
MongoDB Documents

    ✤    Documents live in Collections

    ✤    Documents have no pre-defined schema

    ✤    Documents have key-value pairs, like Perl hashes




Thursday, January 17, 13
MongoDB Documents

    ✤    Documents live in Collections

    ✤    Documents have no pre-defined schema

    ✤    Documents have key-value pairs, like Perl hashes

    ✤    Documents can have nested structure (arrays and other documents),
         like Perl hashes




Thursday, January 17, 13
MongoDB Documents

    ✤    Documents live in Collections

    ✤    Documents have no pre-defined schema

    ✤    Documents have key-value pairs, like Perl hashes

    ✤    Documents can have nested structure (arrays and other documents),
         like Perl hashes

    ✤    Documents look something like JSON


Thursday, January 17, 13
MongoDB Documents

                    {
                           'title': 'Fellowship of the Ring, The',
                           'author': ObjectId("507ffbb1d94ccab2da652597"),
                           'language': 'English',
                           'genre': ['fantasy', 'adventure'],
                           'publication': {
                                'name': 'George Allen & Unwin',
                                'location': 'London',
                                     'date': new Date('21 July 1954'),
                           }
                    }




Thursday, January 17, 13
Class Delegation Structure

              Documents




Thursday, January 17, 13
Class Delegation Structure

              Documents    MongoDB::Cursor




Thursday, January 17, 13
Class Delegation Structure

              Documents     MongoDB::Cursor

                                      has()

                           MongoDB::Collection




Thursday, January 17, 13
Class Delegation Structure

              Documents     MongoDB::Cursor

                                      has()

                           MongoDB::Collection

                                      has()

                           MongoDB::Database




Thursday, January 17, 13
Class Delegation Structure

              Documents      MongoDB::Cursor

                                       has()

                            MongoDB::Collection

                                       has()

                            MongoDB::Database

                                       has()

                           MongoDB::MongoClient




Thursday, January 17, 13
Class Delegation Structure

              Documents      MongoDB::Cursor      Application

                                       has()

                            MongoDB::Collection

                                       has()

                            MongoDB::Database

                                       has()

                           MongoDB::MongoClient




Thursday, January 17, 13
Let’s Build It!




Thursday, January 17, 13
Building the Library




Thursday, January 17, 13
Building the Library




Thursday, January 17, 13
Building the Library




Thursday, January 17, 13
Building the Library




Thursday, January 17, 13
Building the Library

                                  Remember the Genres?
                    {
                            'title': 'Fellowship of the Ring, The',
                           'author': ObjectId("507ffbb1d94ccab2da652597"),
                           'language': 'English',
                           'genre': ['fantasy', 'adventure'],
                           'publication': {
                                'name': 'George Allen & Unwin',
                                'location': 'London',
                                      'date': new Date('21 July 1954'),
                           }
        }




Thursday, January 17, 13
Building the Library




Thursday, January 17, 13
Building the Library




Thursday, January 17, 13
Where to go from here?

    ✤    Learn more about MongoDB:
          ✤    http://docs.mongodb.org/manual/
    ✤    Learn more about the MongoDB Perl API
          ✤    https://metacpan.org/module/MongoDB::Tutorial
    ✤    Hack on the Library demo app
          ✤    https://github.com/friedo/mongo-library
          ✤    Add/edit authors?
          ✤    Edit books?


Thursday, January 17, 13
What’s on CPAN?



    ✤    ODM’s (Object Document Mappers)

          ✤    Like ORMs but simpler




Thursday, January 17, 13
What’s on CPAN?


    ✤    Mongoose:

          ✤    Based on MongoMapper
               from Ruby.

          ✤    MongoDB Docs -->
               Moose objects.




Thursday, January 17, 13
What’s on CPAN?

    ✤    MongoDBI

          ✤    Very Perlish

          ✤    Moose-like Syntax




Thursday, January 17, 13
What’s on CPAN?


    ✤    MongoDB::Async

          ✤    Tracks upstream MongoDB Distribution

          ✤    Uses Coro and libev for asynchronous queries

          ✤    (Mostly) drop-in replacement for MongoDB driver




Thursday, January 17, 13
Questions
    https://github.com/friedo/mongo-library
    http://docs.mongodb.org/manual/
    MongoDB::Tutorial


Thursday, January 17, 13
Ad

More Related Content

Viewers also liked (7)

Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...
Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...
Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...
kiphampton
 
Devoxx 2015, ionic chat
Devoxx 2015, ionic chatDevoxx 2015, ionic chat
Devoxx 2015, ionic chat
Loïc Knuchel
 
Amazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by BeginnerAmazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by Beginner
Hirokazu Tokuno
 
Devoxx 2015, Atelier Ionic - 09/04/2015
Devoxx 2015, Atelier Ionic - 09/04/2015Devoxx 2015, Atelier Ionic - 09/04/2015
Devoxx 2015, Atelier Ionic - 09/04/2015
Loïc Knuchel
 
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Loïc Knuchel
 
Ionic bbl le 19 février 2015
Ionic bbl le 19 février 2015Ionic bbl le 19 février 2015
Ionic bbl le 19 février 2015
Loïc Knuchel
 
Apache Cordova 3.3 de zéro
Apache Cordova 3.3 de zéroApache Cordova 3.3 de zéro
Apache Cordova 3.3 de zéro
Alexandre Pereira
 
Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...
Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...
Stop Making The Web Harder Than It Is; Real-world REST, HATEOAS, and Hypermed...
kiphampton
 
Devoxx 2015, ionic chat
Devoxx 2015, ionic chatDevoxx 2015, ionic chat
Devoxx 2015, ionic chat
Loïc Knuchel
 
Amazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by BeginnerAmazon DynamoDB Lessen's Learned by Beginner
Amazon DynamoDB Lessen's Learned by Beginner
Hirokazu Tokuno
 
Devoxx 2015, Atelier Ionic - 09/04/2015
Devoxx 2015, Atelier Ionic - 09/04/2015Devoxx 2015, Atelier Ionic - 09/04/2015
Devoxx 2015, Atelier Ionic - 09/04/2015
Loïc Knuchel
 
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Loïc Knuchel
 
Ionic bbl le 19 février 2015
Ionic bbl le 19 février 2015Ionic bbl le 19 février 2015
Ionic bbl le 19 février 2015
Loïc Knuchel
 

Similar to Building a MongoDB App with Perl (16)

Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdams
JAX London
 
Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012
Pablo Godel
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDB
Pablo Godel
 
BreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backendBreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backend
Horacio Gonzalez
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with Ruby
Jonathan Holloway
 
MongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB Galaxy
MongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB GalaxyMongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB Galaxy
MongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB Galaxy
MongoDB
 
Mongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappeMongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappe
Spyros Passas
 
Mongo db present
Mongo db presentMongo db present
Mongo db present
scottmsims
 
The elephant in the room mongo db + hadoop
The elephant in the room  mongo db + hadoopThe elephant in the room  mongo db + hadoop
The elephant in the room mongo db + hadoop
iammutex
 
MongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl AppMongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl App
Stennie Steneker
 
Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01
Kaushik Dey
 
JSON, The Argonauts and Mark
JSON, The Argonauts and MarkJSON, The Argonauts and Mark
JSON, The Argonauts and Mark
Mark Smalley
 
Kickstarting Your Mongo Education with MongoDB University
Kickstarting Your Mongo Education with MongoDB UniversityKickstarting Your Mongo Education with MongoDB University
Kickstarting Your Mongo Education with MongoDB University
Juan Carlos Farah
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Pôle Systematic Paris-Region
 
Mongodb
MongodbMongodb
Mongodb
foliba
 
Jesús Barrasa
Jesús BarrasaJesús Barrasa
Jesús Barrasa
Connected Data World
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdams
JAX London
 
Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012
Pablo Godel
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDB
Pablo Godel
 
BreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backendBreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backend
Horacio Gonzalez
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with Ruby
Jonathan Holloway
 
MongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB Galaxy
MongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB GalaxyMongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB Galaxy
MongoDB World 2019: Don't Panic - The Hitchhiker's Guide to the MongoDB Galaxy
MongoDB
 
Mongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappeMongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappe
Spyros Passas
 
Mongo db present
Mongo db presentMongo db present
Mongo db present
scottmsims
 
The elephant in the room mongo db + hadoop
The elephant in the room  mongo db + hadoopThe elephant in the room  mongo db + hadoop
The elephant in the room mongo db + hadoop
iammutex
 
MongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl AppMongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl App
Stennie Steneker
 
Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01
Kaushik Dey
 
JSON, The Argonauts and Mark
JSON, The Argonauts and MarkJSON, The Argonauts and Mark
JSON, The Argonauts and Mark
Mark Smalley
 
Kickstarting Your Mongo Education with MongoDB University
Kickstarting Your Mongo Education with MongoDB UniversityKickstarting Your Mongo Education with MongoDB University
Kickstarting Your Mongo Education with MongoDB University
Juan Carlos Farah
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Pôle Systematic Paris-Region
 
Mongodb
MongodbMongodb
Mongodb
foliba
 
Ad

More from Mike Friedman (9)

Basic Symbolic Computation in Perl
Basic Symbolic Computation in PerlBasic Symbolic Computation in Perl
Basic Symbolic Computation in Perl
Mike Friedman
 
Make Your Own Perl with Moops
Make Your Own Perl with MoopsMake Your Own Perl with Moops
Make Your Own Perl with Moops
Mike Friedman
 
The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)
Mike Friedman
 
21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci
Mike Friedman
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real World
Mike Friedman
 
CPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPANCPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPAN
Mike Friedman
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
Mike Friedman
 
Building Your First App with MongoDB
Building Your First App with MongoDBBuilding Your First App with MongoDB
Building Your First App with MongoDB
Mike Friedman
 
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::ClientBuilding Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Mike Friedman
 
Basic Symbolic Computation in Perl
Basic Symbolic Computation in PerlBasic Symbolic Computation in Perl
Basic Symbolic Computation in Perl
Mike Friedman
 
Make Your Own Perl with Moops
Make Your Own Perl with MoopsMake Your Own Perl with Moops
Make Your Own Perl with Moops
Mike Friedman
 
The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)
Mike Friedman
 
21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci
Mike Friedman
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real World
Mike Friedman
 
CPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPANCPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPAN
Mike Friedman
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
Mike Friedman
 
Building Your First App with MongoDB
Building Your First App with MongoDBBuilding Your First App with MongoDB
Building Your First App with MongoDB
Mike Friedman
 
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::ClientBuilding Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Mike Friedman
 
Ad

Building a MongoDB App with Perl

  • 1. Building Your App: Perl & MongoDB Mike Friedman (friedo) Perl Engineer & Evangelist, 10gen http://friedo.com Perl Oasis 2013 Thursday, January 17, 13
  • 2. 10gen, the MongoDB Company http://www.10gen.com http://www.mongodb.org Thursday, January 17, 13
  • 3. What is MongoDB? Thursday, January 17, 13
  • 4. What is MongoDB? ✤ Document Oriented Database Thursday, January 17, 13
  • 5. What is MongoDB? ✤ Document Oriented Database ✤ Open Source Thursday, January 17, 13
  • 6. What is MongoDB? ✤ Document Oriented Database ✤ Open Source ✤ High Performance Thursday, January 17, 13
  • 7. What is MongoDB? ✤ Document Oriented Database ✤ Open Source ✤ High Performance ✤ Horizontally Scalable Thursday, January 17, 13
  • 8. What is MongoDB? ✤ Document Oriented Database ✤ Open Source ✤ High Performance ✤ Horizontally Scalable ✤ Full Featured Thursday, January 17, 13
  • 9. What We Will Build: ✤ “Library” - A demo application ✤ Users ✤ Books ✤ Authors ✤ Publishers Thursday, January 17, 13
  • 10. What We Will Need: Thursday, January 17, 13
  • 11. What We Will Need: ✤ MongoDB ✤ http://www.mongodb.org/downloads Thursday, January 17, 13
  • 12. What We Will Need: ✤ MongoDB ✤ http://www.mongodb.org/downloads ✤ CPAN Modules: ✤ https://metacpan.org/module/Mojolicious::Lite ✤ https://metacpan.org/module/MongoDB Thursday, January 17, 13
  • 13. Inside the MongoDB CPAN Distribution Thursday, January 17, 13
  • 14. Inside the MongoDB CPAN Distribution ✤ MongoDB::MongoClient Thursday, January 17, 13
  • 15. Inside the MongoDB CPAN Distribution ✤ MongoDB::MongoClient ✤ new in version 0.502. Thursday, January 17, 13
  • 16. Inside the MongoDB CPAN Distribution ✤ MongoDB::MongoClient ✤ new in version 0.502. ✤ “Safe” (write-acknowledged) by default Thursday, January 17, 13
  • 17. Inside the MongoDB CPAN Distribution ✤ MongoDB::MongoClient ✤ new in version 0.502. ✤ “Safe” (write-acknowledged) by default ✤ Encapsulates connection and server info Thursday, January 17, 13
  • 18. Inside the MongoDB CPAN Distribution Thursday, January 17, 13
  • 19. Inside the MongoDB CPAN Distribution ✤ MongoDB::Database ✤ Represents a database (namespace) on the MongoDB server Thursday, January 17, 13
  • 20. Inside the MongoDB CPAN Distribution ✤ MongoDB::Database ✤ Represents a database (namespace) on the MongoDB server ✤ MongoDB::Collection ✤ Represents a collection (table? kinda) in a database Thursday, January 17, 13
  • 21. Inside the MongoDB CPAN Distribution ✤ MongoDB::Database ✤ Represents a database (namespace) on the MongoDB server ✤ MongoDB::Collection ✤ Represents a collection (table? kinda) in a database ✤ MongoDB::Cursor ✤ Retrieves documents (rows? kinda) from a collection Thursday, January 17, 13
  • 23. MongoDB Documents ✤ Documents live in Collections Thursday, January 17, 13
  • 24. MongoDB Documents ✤ Documents live in Collections ✤ Documents have no pre-defined schema Thursday, January 17, 13
  • 25. MongoDB Documents ✤ Documents live in Collections ✤ Documents have no pre-defined schema ✤ Documents have key-value pairs, like Perl hashes Thursday, January 17, 13
  • 26. MongoDB Documents ✤ Documents live in Collections ✤ Documents have no pre-defined schema ✤ Documents have key-value pairs, like Perl hashes ✤ Documents can have nested structure (arrays and other documents), like Perl hashes Thursday, January 17, 13
  • 27. MongoDB Documents ✤ Documents live in Collections ✤ Documents have no pre-defined schema ✤ Documents have key-value pairs, like Perl hashes ✤ Documents can have nested structure (arrays and other documents), like Perl hashes ✤ Documents look something like JSON Thursday, January 17, 13
  • 28. MongoDB Documents { 'title': 'Fellowship of the Ring, The', 'author': ObjectId("507ffbb1d94ccab2da652597"), 'language': 'English', 'genre': ['fantasy', 'adventure'], 'publication': { 'name': 'George Allen & Unwin', 'location': 'London', 'date': new Date('21 July 1954'), } } Thursday, January 17, 13
  • 29. Class Delegation Structure Documents Thursday, January 17, 13
  • 30. Class Delegation Structure Documents MongoDB::Cursor Thursday, January 17, 13
  • 31. Class Delegation Structure Documents MongoDB::Cursor has() MongoDB::Collection Thursday, January 17, 13
  • 32. Class Delegation Structure Documents MongoDB::Cursor has() MongoDB::Collection has() MongoDB::Database Thursday, January 17, 13
  • 33. Class Delegation Structure Documents MongoDB::Cursor has() MongoDB::Collection has() MongoDB::Database has() MongoDB::MongoClient Thursday, January 17, 13
  • 34. Class Delegation Structure Documents MongoDB::Cursor Application has() MongoDB::Collection has() MongoDB::Database has() MongoDB::MongoClient Thursday, January 17, 13
  • 35. Let’s Build It! Thursday, January 17, 13
  • 40. Building the Library Remember the Genres? { 'title': 'Fellowship of the Ring, The', 'author': ObjectId("507ffbb1d94ccab2da652597"), 'language': 'English', 'genre': ['fantasy', 'adventure'], 'publication': { 'name': 'George Allen & Unwin', 'location': 'London', 'date': new Date('21 July 1954'), } } Thursday, January 17, 13
  • 43. Where to go from here? ✤ Learn more about MongoDB: ✤ http://docs.mongodb.org/manual/ ✤ Learn more about the MongoDB Perl API ✤ https://metacpan.org/module/MongoDB::Tutorial ✤ Hack on the Library demo app ✤ https://github.com/friedo/mongo-library ✤ Add/edit authors? ✤ Edit books? Thursday, January 17, 13
  • 44. What’s on CPAN? ✤ ODM’s (Object Document Mappers) ✤ Like ORMs but simpler Thursday, January 17, 13
  • 45. What’s on CPAN? ✤ Mongoose: ✤ Based on MongoMapper from Ruby. ✤ MongoDB Docs --> Moose objects. Thursday, January 17, 13
  • 46. What’s on CPAN? ✤ MongoDBI ✤ Very Perlish ✤ Moose-like Syntax Thursday, January 17, 13
  • 47. What’s on CPAN? ✤ MongoDB::Async ✤ Tracks upstream MongoDB Distribution ✤ Uses Coro and libev for asynchronous queries ✤ (Mostly) drop-in replacement for MongoDB driver Thursday, January 17, 13
  • 48. Questions https://github.com/friedo/mongo-library http://docs.mongodb.org/manual/ MongoDB::Tutorial Thursday, January 17, 13