"hu mongo us"

Document-oriented database

No NoSQL for you!

Come back next year:


Brownie Points

Scale and trade offs


JSON data types

BSON extra types

Hello schemaless

Just like discovering dynamic languages for the 1st time (plus it maps smoothly to dynamic languages).

Not exactly schema less (more of dynamic one):

Collections are created as needed (on write).


Example document

  _id: "September 19th, 2012",
  talks: [
      title:  "Meta-Moose",
      lecturer: "Ynon Perek",
      description: "Using the meta object, dyna ..."
      slides: ""
      title: "Project Euler",
      lecturer: "Shlomi Fish",
    }, { ... }


mongo shell

Basically a JS shell. Let's play with it a bit.


db.products.find({'type': 'case'})

Find all documents in collection products where type is "case" (even if type is an array).


Many query operators, like


Some of the update operators (in addition to save() ):

Programming Languages

Has official support for many languages:

C, C++, C# / .NET, Erlang, Haskell, Java, JavaScript, Lisp, node.JS, Perl, PHP, Python, Ruby, Scala

Plus few unofficial ones.

For Perl, there's MongoDB at CPAN

Perl example

use MongoDB;

my $conn = MongoDB::Connection->new;
my $catalog_db = $conn->pcat;  # pcat db

my $products = $catalog_db->products;  # products collection

my $services = $products->find({type => "service"}); # we get a cursor

while (my $service = $services->next) {
    print $service->{'_id'} . ', ' . $service->{'name'} . "\n";


    name => "Dummy box", type => ["service", "dummy"]

# or

    name => "Dummy box", type => ["service", "dummy"]


# For type service increment price by 20, set the raised flag

    {type => "service"},
    {'$inc' => {monthly_price => 20},  {'$set' => {raised => 1}} }
# with boolean. To get booleans set $MongoDB::BSON::use_boolean to 1

use boolean;
    {type => "service"},
    {'$inc' => {monthly_price => 20},  {'$set' => {raised =>true}} }

Capped collections

Let's talk a bit about capped collections and tailabile cursors.

my $cursor = $coll->find->tailable(1);
for (;;) {
    if (defined(my $doc = $cursor->next)) {
        say $doc;
    else {
        sleep 1;

Something from the trenches


Thank you