SlideShare uma empresa Scribd logo
1 de 48
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

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 chatLoï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 BeginnerHirokazu 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/2015Loï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-2015Loï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 2015Loïc Knuchel
 

Destaque (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...
 
Devoxx 2015, ionic chat
Devoxx 2015, ionic chatDevoxx 2015, ionic chat
Devoxx 2015, ionic chat
 
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
 
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
 
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
 
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
 
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
 

Semelhante a Building Your App with Perl & MongoDB

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 McAdamsJAX London
 
Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012Pablo Godel
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDBPablo Godel
 
BreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backendBreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backendHoracio Gonzalez
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyJonathan 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 GalaxyMongoDB
 
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_joomlafrappeSpyros Passas
 
Mongo db present
Mongo db presentMongo db present
Mongo db presentscottmsims
 
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 + hadoopiammutex
 
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 AppStennie Steneker
 
Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01Kaushik Dey
 
JSON, The Argonauts and Mark
JSON, The Argonauts and MarkJSON, The Argonauts and Mark
JSON, The Argonauts and MarkMark 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 UniversityJuan 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
Mongodbfoliba
 

Semelhante a Building Your App with Perl & MongoDB (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
 
Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012Symfony2 y MongoDB - deSymfony 2012
Symfony2 y MongoDB - deSymfony 2012
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDB
 
BreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backendBreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backend
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with Ruby
 
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
 
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
 
Mongo db present
Mongo db presentMongo db present
Mongo db present
 
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
 
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
 
Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01Hadoop webinar-130808141030-phpapp01
Hadoop webinar-130808141030-phpapp01
 
JSON, The Argonauts and Mark
JSON, The Argonauts and MarkJSON, The Argonauts and Mark
JSON, The Argonauts and Mark
 
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
 
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...
 
Mongodb
MongodbMongodb
Mongodb
 
Jesús Barrasa
Jesús BarrasaJesús Barrasa
Jesús Barrasa
 

Mais de Mike Friedman

Basic Symbolic Computation in Perl
Basic Symbolic Computation in PerlBasic Symbolic Computation in Perl
Basic Symbolic Computation in PerlMike Friedman
 
Make Your Own Perl with Moops
Make Your Own Perl with MoopsMake Your Own Perl with Moops
Make Your Own Perl with MoopsMike 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: CPANciMike Friedman
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real WorldMike Friedman
 
CPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPANCPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPANMike 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 ExamplesMike Friedman
 
Building Your First App with MongoDB
Building Your First App with MongoDBBuilding Your First App with MongoDB
Building Your First App with MongoDBMike 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::ClientMike Friedman
 

Mais de Mike Friedman (9)

Basic Symbolic Computation in Perl
Basic Symbolic Computation in PerlBasic Symbolic Computation in Perl
Basic Symbolic Computation in Perl
 
Make Your Own Perl with Moops
Make Your Own Perl with MoopsMake Your Own Perl with Moops
Make Your Own Perl with Moops
 
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)
 
21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real World
 
CPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPANCPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPAN
 
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
 
Building Your First App with MongoDB
Building Your First App with MongoDBBuilding Your First App with MongoDB
Building Your First App with MongoDB
 
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
 

Building Your App with Perl & MongoDB

  • 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