forked from mojolicious/mojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Using mongodb
mateu edited this page Jan 27, 2011
·
1 revision
Make a helper in startup to access the schema so you can do something like $self->db from your controller
$self->attr(db => sub {
MongoDB::Connection
->new(host => $config->{database_host})
->get_database($config->{database_name});
});
$self->helper('db' => sub { shift->app->db });
The reason for the attr approach is so that each child will init it's own MongoDB connection which is required by the MongoDB driver