• Like
Building a MongoDB App with Perl
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Building a MongoDB App with Perl

  • 2,922 views
Published

This presentation covers the very basics of building a simple web application with MongoDB and the Mojolicious::Lite prototyping framework.

This presentation covers the very basics of building a simple web application with MongoDB and the Mojolicious::Lite prototyping framework.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,922
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
31
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Building Your App: Perl & MongoDB Mike Friedman (friedo) Perl Engineer & Evangelist, 10gen http://friedo.com Perl Oasis 2013Thursday, January 17, 13
  • 2. 10gen, the MongoDB Company http://www.10gen.com http://www.mongodb.orgThursday, January 17, 13
  • 3. What is MongoDB?Thursday, January 17, 13
  • 4. What is MongoDB? ✤ Document Oriented DatabaseThursday, January 17, 13
  • 5. What is MongoDB? ✤ Document Oriented Database ✤ Open SourceThursday, January 17, 13
  • 6. What is MongoDB? ✤ Document Oriented Database ✤ Open Source ✤ High PerformanceThursday, January 17, 13
  • 7. What is MongoDB? ✤ Document Oriented Database ✤ Open Source ✤ High Performance ✤ Horizontally ScalableThursday, January 17, 13
  • 8. What is MongoDB? ✤ Document Oriented Database ✤ Open Source ✤ High Performance ✤ Horizontally Scalable ✤ Full FeaturedThursday, January 17, 13
  • 9. What We Will Build: ✤ “Library” - A demo application ✤ Users ✤ Books ✤ Authors ✤ PublishersThursday, January 17, 13
  • 10. What We Will Need:Thursday, January 17, 13
  • 11. What We Will Need: ✤ MongoDB ✤ http://www.mongodb.org/downloadsThursday, 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/MongoDBThursday, January 17, 13
  • 13. Inside the MongoDB CPAN DistributionThursday, January 17, 13
  • 14. Inside the MongoDB CPAN Distribution ✤ MongoDB::MongoClientThursday, 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 defaultThursday, 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 infoThursday, January 17, 13
  • 18. Inside the MongoDB CPAN DistributionThursday, January 17, 13
  • 19. Inside the MongoDB CPAN Distribution ✤ MongoDB::Database ✤ Represents a database (namespace) on the MongoDB serverThursday, 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 databaseThursday, 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 collectionThursday, January 17, 13
  • 22. MongoDB DocumentsThursday, January 17, 13
  • 23. MongoDB Documents ✤ Documents live in CollectionsThursday, January 17, 13
  • 24. MongoDB Documents ✤ Documents live in Collections ✤ Documents have no pre-defined schemaThursday, January 17, 13
  • 25. MongoDB Documents ✤ Documents live in Collections ✤ Documents have no pre-defined schema ✤ Documents have key-value pairs, like Perl hashesThursday, 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 hashesThursday, 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 JSONThursday, 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 DocumentsThursday, January 17, 13
  • 30. Class Delegation Structure Documents MongoDB::CursorThursday, January 17, 13
  • 31. Class Delegation Structure Documents MongoDB::Cursor has() MongoDB::CollectionThursday, January 17, 13
  • 32. Class Delegation Structure Documents MongoDB::Cursor has() MongoDB::Collection has() MongoDB::DatabaseThursday, January 17, 13
  • 33. Class Delegation Structure Documents MongoDB::Cursor has() MongoDB::Collection has() MongoDB::Database has() MongoDB::MongoClientThursday, January 17, 13
  • 34. Class Delegation Structure Documents MongoDB::Cursor Application has() MongoDB::Collection has() MongoDB::Database has() MongoDB::MongoClientThursday, January 17, 13
  • 35. Let’s Build It!Thursday, January 17, 13
  • 36. Building the LibraryThursday, January 17, 13
  • 37. Building the LibraryThursday, January 17, 13
  • 38. Building the LibraryThursday, January 17, 13
  • 39. Building the LibraryThursday, 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
  • 41. Building the LibraryThursday, January 17, 13
  • 42. Building the LibraryThursday, 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 simplerThursday, 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 SyntaxThursday, 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 driverThursday, January 17, 13
  • 48. Questions https://github.com/friedo/mongo-library http://docs.mongodb.org/manual/ MongoDB::TutorialThursday, January 17, 13