NAME

SimpleDB::Class::ResultSet - An iterator of items from a domain.

VERSION

version 1.0503

DESCRIPTION

This class is an iterator to walk to the items passed back from a query.

Warning: Once you have a result set and you start calling methods on it, it will begin iterating over the result set. Therefore you can't call both next and search, or any other combinations of methods on an existing result set.

Warning: If you call a method like search on a result set which causes another query to be run, know that the original result set must be very small. This is because there is a limit of 20 comparisons per request as a limitation of SimpleDB.

METHODS

The following methods are available from this class.

new ( params )

Constructor.

params

A hash.

simpledb

Required. A SimpleDB::Class object.

item_class

Required. A SimpleDB::Class::Item subclass name.

result

A result as returned from the send_request() method from SimpleDB::Client. Either this or a where is required.

where

A where clause as defined in SimpleDB::Class::SQL. Either this or a result is required.

order_by

An order_by clause as defined in SimpleDB::Class::SQL. Optional.

limit

A limit clause as defined in SimpleDB::Class::SQL. Optional. NOTE:SimpleDB defines a limit as the number of results to limit to each Next Token, but SimpleDB::Class::ResultSet enforces the limit to be more like a traditional relational database, so calling next() after the limit will return undef just as if there were no more results left to display.

consistent

A boolean that if set true will get around Eventual Consistency, but at a reduced performance. Optional.

set

A hash reference of attribute names and values, which will be set on the item as next is called. Doing so helps to prevent stale object references.

item_class ( )

Returns the item_class passed into the constructor.

consistent ( )

Returns the consistent value passed into the constructor.

set ( )

Returns the set value passed into the constructor.

where ( )

Returns the where passed into the constructor.

order_by ( )

Returns the order_by passed into the constructor.

limit ( )

Returns the limit passed into the constructor.

simpledb ( )

Returns the simpledb passed into the constructor.

result ( )

Returns the result passed into the constructor, or the one generated by fetch_result() if a where is passed into the constructor.

has_result ()

A boolean indicating whether a result was passed into the constructor, or generated by fetch_result().

iterator ( )

Returns an integer which represents the current position in the result set as traversed by next().

limit_counter ( )

Returns an integer representing how many items have been traversed so far by next(). When this reaches the value of limit then no more results will be returned by next().

fetch_result ( [ next ] )

Fetches a result, based on a where clause passed into a constructor, and then makes it accessible via the result() method.

next

A next token, in order to fetch the next part of a result set.

count ( [ options ] )

Counts the items in the result set. Returns an integer.

options

A hash of extra options you can pass to modify the count.

where

A where clause as defined by SimpleDB::Class::SQL. If this is specified, then an additional query is executed before counting the items in the result set.

search ( options )

Just like "search" in SimpleDB::Class::Domain, but searches within the confines of the current result set, and then returns a new result set.

options

A hash of extra options to modify the search.

where

A where clause as defined by SimpleDB::Class::SQL.

update ( attributes )

Calls update and then put on all the items in the result set.

attributes

A hash reference containing name/value pairs to update in each item.

delete ( )

Calls delete on all the items in the result set.

paginate ( items_per_page, page_number )

Use on a new result set to fast forward to the desired data. After you've paginated, you can call next to start fetching your data. Returns a reference to the result set for easy method chaining.

NOTE: Unless you've already set a limit, the limit for this result set will be set to items_per_page as a convenience.

items_per_page

An integer representing how many items you're fetching/displaying per page.

page_number

An integer representing what page number you'd like to skip ahead to.

next ()

Returns the next result in the result set. Also fetches th next partial result set if there's a next token in the first result set and you've iterated through the first partial set.

to_array_ref ()

Returns an array reference containing all the objects in the result set. If the result set has already been partially walked, then only the remaining objects will be returned.

LEGAL

SimpleDB::Class is Copyright 2009-2010 Plain Black Corporation (http://www.plainblack.com/) and is licensed under the same terms as Perl itself.