The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catalyst::Model::MongoDB - MongoDB model class for Catalyst

VERSION

version 0.13

SYNOPSIS

    #
    # Config
    #
    <Model::MyModel>
        host localhost
        port 27017
        dbname mydatabase
        username myuser
        password mypass
        collectionname preferedcollection
        gridfs preferedgridfs
    </Model::MyModel>

    #
    # Usage
    #
    $c->model('MyModel')->db                           # returns MongoDB::MongoClient->get_database
    $c->model('MyModel')->db('otherdb')                # returns ->otherdb
    $c->model('MyModel')->collection                   # returns ->mydatabase->preferedcollection
    $c->model('MyModel')->coll                         # the same...
    $c->model('MyModel')->c                            # the same...
    $c->model('MyModel')->c('otherdb.othercollection') # returns ->otherdb->othercollection
    $c->model('MyModel')->c('somecollection')          # returns ->mydatabase->somecollection
    $c->model('MyModel')->gridfs                       # returns ->mydatabase->get_gridfs('preferedgridfs')
    $c->model('MyModel')->g                            # the same...
    $c->model('MyModel')->g('somegridfs')              # returns ->mydatabase->get_gridfs('somegridfs')
    $c->model('MyModel')->g('otherdb.othergridfs')     # returns ->otherdb->get_gridfs('othergridfs')

    $c->model('MyModel')->run(...)                     # returns ->mydatabase->run_command(...)
    $c->model('MyModel')->eval(...)                    # returns ->mydatabase->eval(...)

    $c->model('MyModel')->database_names               # returns ->database_names
    $c->model('MyModel')->dbnames                      # the same...

DESCRIPTION

This model class exposes MongoDB::MongoClient as a Catalyst model.

CONFIGURATION

You can pass the same configuration fields as when you make a new MongoDB::MongoClient.

In addition you can also give a database name via dbname, a collection name via collectioname or a gridfs name via gridfsname.

AUTHENTICATION

If all three of username, password, and dbname are present, this class will authenticate via MongoDB::MongoClient->authenticate(). (See MongoDB::MongoClient for details).

METHODS

dbnames

database_names

List of databases.

collnames

collection_names

List of collection names of the default database. You cant give other database names here, if you need this please do:

  $c->model('MyModel')->db('otherdatabase')->collection_names

collection

coll

c

Gives back a MongoDB::Collection, you can also directly access other dbs collections, with "otherdb.othercollection". If no collectionname is given he uses the default collectionname given on config.

gridfs

g

Gives back a MongoDB::GridFS. If no gridfsname is given, he uses the default gridfsname given on config.

run

Run a command via MongoDB::Database->run_command on the default database. You cant give other database names here, if you need this please do:

  $c->model('MyModel')->db('otherdatabase')->run_command(...)

eval

Eval code via MongoDB::Database->eval on the default database. You cant give other database names here, if you need this please do:

  $c->model('MyModel')->db('otherdatabase')->eval(...)

oid

Creates MongoDB::OID object

authenticate

[re]authenticate after the initial connection, or authenticate to multiple databases within the same model.

SUPPORT

IRC

  Join #catalyst on irc.perl.org and ask for Getty.

Repository

  http://github.com/singingfish/p5-catalyst-model-mongodb
  Pull request and additional contributors are welcome

Issue Tracker

  http://github.com/singingfish/p5-catalyst-model-mongodb/issues

AUTHOR

Torsten Raudssus <torsten@raudssus.de> http://www.raudssus.de/

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Raudssus Social Software.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.