9. Rule of least surprise
• Write clearly a side effect
• e.g.) insert => execute insert only
• e.g.) insert_and_fetch_id
• e.g.) insert_and_fetch_row
• No write clearly, No do it.
16. Object Mapping
• Map a row to a row object
• Can change the class of object each tables
• Map rows to a collection object
• Also you can it too :)
• And, you can disable it, If you want.
17. Example:
# $rows is a Aniki::Result::Collection
my $rows = $db->select(user => {});
$rows->first; ## first of row
18. Example:
# $rows is a Array
my $rows = $db->select(user => {}, {
suppress_result_object => 1,
});
$rows->[0]; ## first of row
19. Example:
# $row is a Aniki::Result::Row
my $row = $db->select(user => {
id => 1,
}, {
limit => 1,
})->first;
$row->id; ## => 1
20. Example:
# $row is a Hash
my $row = $db->select(user => {
id => 1,
}, {
limit => 1,
suppress_row_objects => 1,
})->first;
$row->{id}; ## => 1