#MongoDB

MongoDB Mojo:
Building a basic Perl app
Stephen Steneker (@stennie)
Community Support Manager, MongoDB
MongoDB is a ___________ database
•  Document oriented
•  Open source
•  High performance
•  Horizontally scalable
•  Full...
High Performance
•  Written in C++
•  Extensive use of memory-mapped files

i.e. read-through write-through memory caching....
Scalability & Performance

Database Landscape
Memcached
MongoDB

RDBMS

Depth of Functionality
Full Featured
•  Ad Hoc queries
•  Real time aggregation
•  Rich query capabilities
•  Strongly consistent
•  Geospatial f...
What We Will Build:
•  “Library”: A demo application
–  Users
–  Books
–  Authors
–  Publishers

Photo by Jessica Spengler...
What We Will Need:
•  MongoDB
–  http://www.mongodb.org/downloads
•  CPAN Modules:
–  https://metacpan.org/module/Mojolici...
Inside the CPAN Distribution: Requirements
•  Moose
•  DateTime
•  Digest::MD5
•  Tie::IxHash
•  XSLoader
•  boolean
Inside the CPAN Distribution: Client
•  MongoDB::MongoClient
–  new in version 0.502 (Nov-2012)
–  “Safe” (write-acknowled...
Inside the MongoDB CPAN Distribution: Classes
•  MongoDB::Database
–  Represents a database (namespace) on the MongoDB ser...
MongoDB Documents
•  Documents live in Collections
•  Documents have no pre-defined schema
•  Documents have key-value pair...
MongoDB Documents
{
'title': 'Fellowship of the Ring, The',
'author': ObjectId("507ffbb1d94ccab2da652597"),
'language': 'E...
Class Delegation Structure
Documents

MongoDB::Cursor

Application
has()!

MongoDB::Collection
has()!
MongoDB::Database
ha...
Let’s Build It!
Building the Library
Building the Library
Building the Library
Building the Library
Building the Library
Remember the Genres?
{
'title': 'Fellowship of the Ring, The',
'author': ObjectId("507ffbb1d94ccab2da...
Building the Library
Building the Library
What’s on CPAN?
•  ODMs (Object Document Mappers)
–  Like ORMs but simpler
Mongoose
•  Based on MongoMapper

from Ruby.
•  MongoDB Docs -->

Moose objects.

http://search.cpan.org/~rodrigo/Mongoose...
MongoDBI
•  Very Perlish
•  Moose-like Syntax

http://search.cpan.org/~awncorp/MongoDBI-0.02/ (17-Oct-2012)
MongoDB::Async
•  Tracks upstream MongoDB Distribution
•  Uses Coro and libev for asynchronous queries
•  (Mostly) drop-in...
Where to from here?
•  Learn more about MongoDB

–  http://docs.mongodb.org
•  Learn about the MongoDB Perl API

–  https:...
#MongoDB

Thank You!
Stephen Steneker
stennie@mongodb.com

(@stennie)
Upcoming SlideShare
Loading in...5
×

MongoDB Mojo: Building a Basic Perl App

1,709

Published on

Building a basic app using MongoDB + Perl. From Sydney Perl Mongers meetup (September, 2013).

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,709
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

MongoDB Mojo: Building a Basic Perl App

  1. 1. #MongoDB MongoDB Mojo: Building a basic Perl app Stephen Steneker (@stennie) Community Support Manager, MongoDB
  2. 2. MongoDB is a ___________ database •  Document oriented •  Open source •  High performance •  Horizontally scalable •  Full featured
  3. 3. High Performance •  Written in C++ •  Extensive use of memory-mapped files i.e. read-through write-through memory caching. •  Runs nearly everywhere •  Data serialized as BSON (fast parsing) •  Full support for primary & secondary indexes •  Document model = less work
  4. 4. Scalability & Performance Database Landscape Memcached MongoDB RDBMS Depth of Functionality
  5. 5. Full Featured •  Ad Hoc queries •  Real time aggregation •  Rich query capabilities •  Strongly consistent •  Geospatial features •  Support for most programming languages •  Flexible schema
  6. 6. What We Will Build: •  “Library”: A demo application –  Users –  Books –  Authors –  Publishers Photo by Jessica Spengler: http://www.flickr.com/photos/wordridden/6798197508/
  7. 7. What We Will Need: •  MongoDB –  http://www.mongodb.org/downloads •  CPAN Modules: –  https://metacpan.org/module/Mojolicious::Lite –  https://metacpan.org/module/MongoDB
  8. 8. Inside the CPAN Distribution: Requirements •  Moose •  DateTime •  Digest::MD5 •  Tie::IxHash •  XSLoader •  boolean
  9. 9. Inside the CPAN Distribution: Client •  MongoDB::MongoClient –  new in version 0.502 (Nov-2012) –  “Safe” (write-acknowledged) by default –  Encapsulates connection and server info
  10. 10. Inside the MongoDB CPAN Distribution: Classes •  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
  11. 11. 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
  12. 12. 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'), } }
  13. 13. Class Delegation Structure Documents MongoDB::Cursor Application has()! MongoDB::Collection has()! MongoDB::Database has()! MongoDB::MongoClient
  14. 14. Let’s Build It!
  15. 15. Building the Library
  16. 16. Building the Library
  17. 17. Building the Library
  18. 18. Building the Library
  19. 19. 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'), } }
  20. 20. Building the Library
  21. 21. Building the Library
  22. 22. What’s on CPAN? •  ODMs (Object Document Mappers) –  Like ORMs but simpler
  23. 23. Mongoose •  Based on MongoMapper from Ruby. •  MongoDB Docs --> Moose objects. http://search.cpan.org/~rodrigo/Mongoose-0.23/ (28-Jan-2013)
  24. 24. MongoDBI •  Very Perlish •  Moose-like Syntax http://search.cpan.org/~awncorp/MongoDBI-0.02/ (17-Oct-2012)
  25. 25. MongoDB::Async •  Tracks upstream MongoDB Distribution •  Uses Coro and libev for asynchronous queries •  (Mostly) drop-in replacement for MongoDB driver http://search.cpan.org/~nyaknyan/MongoDB-Async-0.503.2/ (22-Dec-2012)
  26. 26. Where to from here? •  Learn more about MongoDB –  http://docs.mongodb.org •  Learn about the MongoDB Perl API –  https://metacpan.org/module/MongoDB::Tutorial •  Community support –  http://stackoverflow.com/tags/mongodb –  https://groups.google.com/group/mongodb-user •  MongoDB University –  http://education.mongodb.com/
  27. 27. #MongoDB Thank You! Stephen Steneker stennie@mongodb.com (@stennie)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×