File::DataClass::ResultSet - Core result management methods
use File:DataClass; my $attr = { result_source_attributes => { schema_attributes => { ... } } }; my $result_source = File::DataClass->new( $attr )->result_source; my $rs = $result_source->resultset( { path => q(path_to_data_file) } ); my $result = $rs->search( $hash_ref_of_where_clauses ); for my $result_object ($result->next) { # Do something with the result object }
Find, search and update methods for element objects
Defines these attributes
list_class
List class name, defaults to File::DataClass::List
result_class
Result class name, defaults to File::DataClass::Result
result_source
An object reference to the File::DataClass::ResultSource instance that created this result set
_iterator
Contains the integer count of the position within the _results hash. Incremented by each call to "next"
_results
_operators
A hash ref of coderefs that implement the comparison operations performed by the "search" method
An array of result objects. Produced by calling "search"
@results = $rs->search()->all;
Returns all the result object references that were found by the "search" call
$result_object_ref = $rs->create( $args );
Creates and inserts an new record. The $args hash requires the id of the record to create. Missing attributes are defaulted from the defaults attribute of the File::DataClass::Schema object. Returns the new record's object reference
$args
id
defaults
This behaviour changed after 0.41. It used to return the new record id
$result_object_ref = $rs->create_or_update( $args );
Creates a new record if it does not already exist, updates the existing one if it does. Returns the record's object reference
This behaviour changed after 0.41. It used to return the record id
$record_id = $rs->delete( $id_of_record_to_delete ); $record_id = $rs->delete( { id => $record_to_delete, optional => $bool } );
Deletes a record. Returns the id of the deleted record. By default the optional flag is false and if the record does not exist an exception will be thrown. Setting the flag to true avoids the exception and undef is returned instead
optional
undef
$result_object_ref = $rs->find( $id_of_record_to_find } );
Finds the named record and returns an result object reference for it
$result_object_ref = $rs->find_and_update( $args );
Finds the named result object and updates it's attributes
This behaviour changed after 0.41. It used to return the result id
$result_object_ref = $rs->search( $where_clauses )->first;
Returns the first result object that was found by the /search call
/search
$list_object_ref = $rs->list( { id => $id } );
Returns a list object reference
Retrieves the named record and a list of record ids
$result_object_ref = $rs->search( $where_clauses )->last;
Returns the last result object that was found by the /search call
$result_object_ref = $rs->search( $where_clauses )->next;
Iterate over the results returned by the /search call
$path = $rs->path;
Attribute "path" in File::DataClass::Schema
$added = $rs->push( { name => $id, list => $list, items => $items } );
Adds items to the attribute list. The $args hash requires these keys; id the element to edit, list the attribute of the named element containing the list of existing items, req the request object and items the field on the request object containing the list of new items
list
req
items
$rs->reset
Resets the resultset's cursor, so you can iterate through the search results again
$result = $rs->search( $hash_ref_of_where_clauses );
Search for records that match the given criterion. The criterion is a hash reference whose keys are record attribute names. The criterion values are either scalar values or hash references. The scalar values are tested for equality with the corresponding record attribute values. Hash reference keys are treated as comparison operators, the hash reference values are compared with the record attribute values, e.g.
{ 'some_element_attribute_name' => { '>=' => 0 } }
$hash = $rs->select;
Returns a hash ref of records
$removed = $rs->splice( { name => $id, list => $list, items => $items } );
Removes items from the attribute list
$storage = $rs->storage;
Attribute "storage" in File::DataClass::Schema
$rs->update( { id => $of_element, fields => $attr_hash } );
Updates the named element
Calls "txn_do" in File::DataClass::Storage
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2017 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install File::DataClass, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::DataClass
CPAN shell
perl -MCPAN -e shell install File::DataClass
For more information on module installation, please visit the detailed CPAN module installation guide.