NAME

Entities::Backend::MongoDB - Stores all Entities data in a MongoDB database.

VERSION

version 0.5

SYNOPSIS

use Entities;
use Entities::Backend::MongoDB;
# see synopsis at L<Entities>

DESCRIPTION

This backend for the Entities user management and authorization system stores all entities and relations between them in a MongoDB database, using the MongoDB module. This is a powerful, fast backend that gives you all the features of MongoDB. This is the only backend right now that can be used in production environments.

A big advantage of using this backend is that there is no setup work necessary. Just make sure your MongoDB daemon is running, and this backend will automatically create the database and necessary collections.

UNIQUE METHODS

The following method are unique to this backend only.

new( [ host => 'localhost', port => 27017, db_name => 'entities' ] )

Creates a new instance of this module. Can receive the hostname of the server running the MongoDB daemon, the port on that host where the daemon is listening, and the name of the database to use. None of these parameters is required, host will default to 'localhost', port will default to 27017 (the default MongoDB port) and db_name will default to 'entities'.

host()

Returns the host name or IP of the MongoDB server.

port()

Returns the port number on the host where the MongoDB server listens.

db_name()

Returns the name of the database into which all data is saved.

db( [$db_obj] )

Returns the MongoDB::Database object used for actually storing and retrieving data. If a MongoDB::Database object is provided, it will replace the current object.

to_hash( $obj )

Receives an entity object (either user, action, role, feature, plan or customer) and turns it into a hash-ref that can be saved in the database.

METHODS IMPLEMENTED

The following methods implement the methods that the Entities::Backend Moose role requires backend classes to implement. See the documentation of that role for more information on these methods.

get_user_from_id( $user_id )

get_user_from_name( $username )

get_role( $role_name )

get_customer( $customer_name )

get_plan( $plan_name )

get_feature( $feature_name )

get_action( $action_name )

save( $obj )

METHOD MODIFIERS

The following list documents any method modifications performed through the magic of Moose.

BUILD()

This method is automatically invoked immediately after the new() method is invoked. It is used to initiate the connection to the MongoDB database and store it in the object.