++ed by:

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

Mariano Wahlmann


Gideon::Manual::Updating - Updating objects


version 0.0.3


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');
    # 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.


Updating objects with Gideon


version 0.0.3


Mariano Wahlmann, Gines Razanov


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