++ed by:
DICHI

1 PAUSE user(s)
1 non-PAUSE user(s).

Mariano Wahlmann

NAME

Gideon::Manual::Updating - Updating objects

VERSION

version 0.0.3

DESCRIPTION

Gideon can update a single object or a group objects depending on how it is invoked, please make sure you read and understand the documentation as missues of this method can cause data corruption

update( %changes ) as a Class method

When update is invoked for a Gideon class it updates all records in a data store with %changes.

    # Update all objects in the data store
    People->update( status => 'active' );

update( %changes ) as an Instance method

When update is invoked for a Gideon class instance it updates that particular record and not the rest of the records

    # Update one object
    People->find_one( id => 1 )->update( id => 2 );

Updating object with save

Additionally you can use the save method to update a particular object.

    my $person = People->find_one( id => 1 );
    
    # Update only the name
    $person->update( name => 'John Doe' );
    # Query: UPDATE ... SET name = 'John Doe' WHERE id = 1

    # Update names
    $person->name('John Doe');
    $person->save;
    # Query: UPDATE ... SET id = 1, name = 'John Doe', ... WHERE id = 1

The difference between save and update is that update gives you a fine grained control on which fields to update. save sends the entire record as a whole to the data store.

NAME

Updating 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.




Hosting generously
sponsored by Bytemark