# PODNAME: MongoDB::Examples # ABSTRACT: Some examples of MongoDB syntax __END__ =pod =head1 NAME MongoDB::Examples - Some examples of MongoDB syntax =head1 VERSION version 0.503.3 =head1 MAPPING SQL TO MONGODB For developers familiar with SQL, the following chart should help you see how many common SQL queries could be expressed in MongoDB. These are Perl-specific examples of translating SQL queries to MongoDB's query language. To see the JavaScript (or other languages') mappings, see L. In the following examples, C<$db> is a L object which was retrieved by using C. See L for more. =over =item C Implicit, can be done explicitly. =item C $db->get_collection( 'users' )->insert( { a => 1, b => 1 } ); =item C $db->get_collection( 'users' )->find; =item C $db->get_collection( 'users' )->find( { age => 33 }, { a => 1, b => 1 } ); =item C33>> $db->get_collection( 'users' )->find( { age => { '$gt' => 33 } } ); =item C< $db->get_collection( 'users' )->find( { name => qr/Joe/ } ); =item C33 AND age<=40>> $db->get_collection( 'users' )->find( { age => { '$gt' => 33, '$lte' => 40 } } ); =item C $db->get_collection( 'users' )->find( {a => 1, b => "q" } ); =item C $db->get_collection( 'users' )->find( { '$or' => [ {a => 1 }, { b => 2 } ] } ); =item C $db->run_command( { distinct => "users", key => "last_name" } ); =item C 30>> $db->get_collection( 'users' )->find( { "age" => { '$gt' => 30 } } )->count; =item C