redis3m  1.0.0
 All Classes Functions Variables Enumerations Pages
Public Member Functions | List of all members
redis3m::patterns::orm< Model > Class Template Reference

Object-Redis-Mapper is a convenient pattern to store object on Redis. Useful when you need classic CRUD operations. It's compatible and inspired by http://github.com/soveran/ohm. Data can be indexed and it supports also uniques. To use it make a subclass of model to model your attribute and use it to fill orm template parameter. More...

#include <orm.h>

Public Member Functions

Model find_by_id (connection::ptr_t conn, const std::string &id)
 As the name says, get an object from id specifying it's unique identifier. More...
 
Model find_by_unique_field (connection::ptr_t conn, const std::string &field, const std::string &value)
 Find an object by using a unique field. More...
 
bool exists_by_id (connection::ptr_t conn, const std::string &id)
 Check if an object exists or not. More...
 
std::string save (connection::ptr_t conn, const Model &model)
 Save an object on database, or update it if it's already present. More...
 
void remove (connection::ptr_t conn, const Model &model)
 Remove object and all related data from database. More...
 
std::vector< std::string > list_members (connection::ptr_t conn, const Model &m, const std::string &list_name)
 
void set_add (connection::ptr_t conn, const Model &m, const std::string &set_name, const std::string &entry)
 
void set_remove (connection::ptr_t conn, const Model &m, const std::string &set_name, const std::string &entry)
 
std::set< std::string > set_members (connection::ptr_t conn, const Model &m, const std::string &set_name)
 
std::string collection_key ()
 Redis key of a SET containing all object ids. Useful for custom operations. Pay attention to mantain compatibility with all other functions. More...
 
std::string collection_id_key ()
 Key containing an incremental counter, used to generate an id for new objects. Useful for custom operations. Pay attention to mantain compatibility with all other functions. More...
 
std::string model_key (const std::string &id)
 Returns Redis Key used to save object data. More...
 
std::string tracked_key (const std::string &id, const std::string &key)
 Returns full key, related to object. More...
 
std::string indexed_field_key (const std::string &field, const std::string &value)
 
std::string unique_field_key (const std::string &field)
 

Detailed Description

template<typename Model>
class redis3m::patterns::orm< Model >

Object-Redis-Mapper is a convenient pattern to store object on Redis. Useful when you need classic CRUD operations. It's compatible and inspired by http://github.com/soveran/ohm. Data can be indexed and it supports also uniques. To use it make a subclass of model to model your attribute and use it to fill orm template parameter.

Member Function Documentation

template<typename Model >
std::string redis3m::patterns::orm< Model >::collection_id_key ( )
inline

Key containing an incremental counter, used to generate an id for new objects. Useful for custom operations. Pay attention to mantain compatibility with all other functions.

Returns
template<typename Model >
std::string redis3m::patterns::orm< Model >::collection_key ( )
inline

Redis key of a SET containing all object ids. Useful for custom operations. Pay attention to mantain compatibility with all other functions.

Returns
template<typename Model >
bool redis3m::patterns::orm< Model >::exists_by_id ( connection::ptr_t  conn,
const std::string &  id 
)
inline

Check if an object exists or not.

Parameters
conn
idUnique identifier
Returns
template<typename Model >
Model redis3m::patterns::orm< Model >::find_by_id ( connection::ptr_t  conn,
const std::string &  id 
)
inline

As the name says, get an object from id specifying it's unique identifier.

Parameters
conn
id
Returns
Use model.loaded() to check if it's valid or not
template<typename Model >
Model redis3m::patterns::orm< Model >::find_by_unique_field ( connection::ptr_t  conn,
const std::string &  field,
const std::string &  value 
)
inline

Find an object by using a unique field.

Parameters
conn
fieldname of field, should be returned by model::uniques
value
Returns
Use model.loaded() to check if it's valid or not
template<typename Model >
std::string redis3m::patterns::orm< Model >::model_key ( const std::string &  id)
inline

Returns Redis Key used to save object data.

Parameters
id
Returns
template<typename Model >
void redis3m::patterns::orm< Model >::remove ( connection::ptr_t  conn,
const Model &  model 
)
inline

Remove object and all related data from database.

Parameters
conn
model
template<typename Model >
std::string redis3m::patterns::orm< Model >::save ( connection::ptr_t  conn,
const Model &  model 
)
inline

Save an object on database, or update it if it's already present.

Parameters
conn
model
Returns
unique identifier of the object, a new one on creation.
template<typename Model >
std::string redis3m::patterns::orm< Model >::tracked_key ( const std::string &  id,
const std::string &  key 
)
inline

Returns full key, related to object.

Parameters
id
key
Returns

The documentation for this class was generated from the following file: