Name
File::DataClass::ResultSet - Core element methods
Synopsis
use File:DataClass;
$attrs = { result_source_attributes => { schema_attributes => { ... } } };
$result_source = File::DataClass->new( $attrs )->result_source;
$rs = $result_source->resultset( { path => q(path_to_data_file) } );
$result = $rs->search( $hash_ref_of_where_clauses );
for $result_object ($result->next) {
# Do something with the result object
}
Description
Find, search and update methods for element objects
Configuration and Environment
Defines these attributes
list_class
-
List class name, defaults to File::DataClass::List
result_class
-
Result class name, defaults to File::DataClass::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" _operators
-
A hash ref of coderefs that implement the comparison operations performed by the "search" method
_results
-
An array of result objects. Produced by calling "search"
Subroutines/Methods
all
@elements = $rs->search()->all;
Returns all the elements that are returned by the "search" call
create
$new_element_name = $rs->create( $args );
Creates and inserts an new element. The $args
hash requires these keys; name
of the element to create and fields
is a hash containing the attributes of the new element. Missing attributes are defaulted from the defaults
attribute of the File::DataClass::Schema object. Returns the new element's name
create_or_update
$element_name = $rs->create_or_update( $args );
Creates a new element if it does not already exist, updates the existing one if it does. Calls "_find_and_update"
delete
$rs->delete( { name => $of_element_to_delete } );
Deletes an element
find
$result_object = $rs->find( { name => $of_element_to_find } );
Finds the named element and returns an element object for it
_find_and_update
$updated_element_name = $rs->_find_and_update( $args );
Finds the named element object and updates it's attributes. Does not wrap the find and update in a transaction
first
$result_object = $rs->search( $where_clauses )->first;
Returns the first element object that is the result of the search call
list
$list_obect = $rs->list( { name => $name } );
Returns a list object
Retrieves the named element and a list of elements
last
$result_object = $rs->search( $where_clauses )->last;
Returns the last element object that is the result of the search call
next
$result_object = $rs->search( $where_clauses )->next;
Iterate over the elements returned by the search call
path
$path = $rs->path;
Attribute "path" in File::DataClass::Schema
push
$added = $rs->push( { name => $name, list => $list, items => $items } );
Adds items to the attribute list. The $args
hash requires these keys; name
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
reset
$rs->reset
Resets the resultset's cursor, so you can iterate through the elements again
search
$result = $rs->search( $hash_ref_of_where_clauses );
Search for elements that match the given criterion. The criterion is a hash ref whose keys are element attribute names. The criterion values are either scalar values or hash refs. The scalar values are tested for equality with the corresponding element attribute values. Hash ref keys are treated as comparison operators, the hash ref values are compared with the element attribute values, e.g.
{ 'some_element_attribute_name' => { '>=' => 0 } }
select
$hash = $rs->select;
Returns a hash ref of elements
splice
$removed = $rs->splice( { name => $name, list => $list, items => $items } );
Removes items from the attribute list
storage
$storage = $rs->storage;
Attribute "storage" in File::DataClass::Schema
update
$rs->update( { name => $of_element, fields => $attr_hash } );
Updates the named element
_txn_do
Calls "txn_do" in File::DataClass::Storage
Diagnostics
None
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Author
Peter Flanigan, <Support at RoxSoft.co.uk>
License and Copyright
Copyright (c) 2014 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