Coat::Persistent::Types::MySQL -- Attribute types and coercions for MySQL data types
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 convinient for updates.
This is possible by using the types defined in this module.
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.
The following types are provided by this module
Alexis Sukrieh <firstname.lastname@example.org>