Coat::Persistent::Types::MySQL(3) Attribute types and coercions for MySQL data types

DESCRIPTION

The types defined in this module are here to provide simple and transparent storage of MySQL data types. This is done for atttributes you want to store with a different value than the one the object has.

For instance, if you have a datetime field, you may want to store it as a MySQL ``datetime'' format (YYYY-MM-DD HH:MM:SS) and handle it in your code as a timestamp, which is much more convenient for updates.

This is possible by using the types defined in this module.

EXAMPLE

We have a 'created_at' attribute, we want to handle it as a timestamp and store it as a MySQL datetime field.

    use Coat::Persistent::Types::MySQL;
    has_p 'created_at' => (
        is => 'rw',
        isa => 'Int', 
        store_as => 'MySQL:DateTime, 
    );

Then, whenever a value that validates the MySQL:DateTime format is assigned to that field, it will be coerced to an Int. On the other hand, whenever an entry has to be saved, the value used for storage will be the result of a coercion from Int to MySQL:DateTime.

TYPES

The following types are provided by this module
MySQL:DateTime : YYYY-MM-DD HH:MM:SS
MySQL:Date : YYYY-MM-DD

AUTHOR

Alexis Sukrieh <[email protected]>