NAME
Gideon::Manual::Creating - Creating objects
VERSION
version 0.0.3
DESCRIPTION
You can easily persist new object in any gideon data store by using the save
method
save([ %opts ])
To store a new object you just simply need to call the save
method on any newly created instance. And returns the object if the saving was successful or undef
if the saving operation failed.
my $new_person = People->new( age => 34, name => 'Mike' );
say 'Success' if $new_person->save;
Gideon has a plugin that would rise an exception in case the operation fails rather than returning undef
. Please refer to Gideon::Plugin::StrictMode for more details.
my $new_person = People->new( age => 34, name => 'Mike' );
try {
$new_person->save( -strict => 1 );
say 'Success';
}
catch {
say 'Failed';
};
In the case of objects persisted into RDB's and auto increment values, Gideon would auto populate the resulting id back into the object
my $new_person = People->new( age => 34, name => 'Mike' );
say $new_person->id; # undef
$new_person->save;
say $new_person->id; # '1'
NAME
Creating objects with Gideon
VERSION
version 0.0.3
AUTHOR
Mariano Wahlmann, Gines Razanov
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Mariano Wahlmann, Gines Razanov.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.