On Wed, Sep 14, 2011 at 11:44 AM, Roland Philibert <[email protected]>wrote:
> I did try what you suggest as per:
> sub thing_GET {
>
> my ($self, $c) = @_;
> $self->status_ok(
> $c,
> entity => $rs =
> $c->model('DB::data)->search({},{result_class =>
> 'DBIx::Class::ResultClass::HashRefInflator',})->all
> );
> }
> ...but the json rest object was showing just the number of row retrieved
> ie: {"rest":80}
>
>
That is not quite what Ian suggested. Scalar assignment (i.e. $rs =)
provides scalar context to the right-hand side, so you're calling all() in
scalar context, so you get the number of elements. Also, the assignment to
$rs is misleading, as you're not actually assigning a ResultSet object to
it, but rather the result of calling ->all() on a ResultSet.
Try one of these approaches instead, which all do the same thing in slightly
different ways. Ian's original suggestion:
@arr = $c->model('DB::data)->search({},{result_class
=> 'DBIx::Class::ResultClass::HashRefInflator',});
...
entity => \@arr
...
or, with an anonymous array instead of a temporary array variable:
...
entity => [$c->model('DB::data)->search({},{result_class
=> 'DBIx::Class::ResultClass::HashRefInflator',})]
...
or, assigning the ResultSet to $rs first:
$rs = $c->model('DB::data)->search({},{result_class
=> 'DBIx::Class::ResultClass::HashRefInflator',});
...
entity => [$rs->all],
...
Ronald
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/