Skip to content

Commit

Permalink
Merge pull request #8 from Worteks/return-array-ref
Browse files Browse the repository at this point in the history
Make sure searchOn and GKFAS return an arrayref
  • Loading branch information
guimard authored Sep 26, 2019
2 parents 04070aa + d918225 commit 4250a0c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/Apache/Session/MongoDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,35 @@ sub _query {
$cursor =
$cursor->fields( { map { $_ => 1 } @fields, "_session_id" => 1 } );
}
my $res;
my %res;
while ( my $r = $cursor->next ) {
my $id = $r->{_session_id};
delete $r->{_id};
$res->{$id} = $r;
$res{$id} = $r;
}
return $res;
return \%res;
}
sub get_key_from_all_sessions {
my ( $class, $args, $data ) = @_;
my $col = $class->_col($args);
my $col = $class->_col($args);
my $cursor = $col->find( {} );
my $res;
my %res;
while ( my $r = $cursor->next ) {
my $id = $r->{_session_id};
delete $r->{_id};
if ( ref($data) eq 'CODE' ) {
$res->{$id} = $data->( $r, $id );
$res{$id} = $data->( $r, $id );
}
elsif ($data) {
$data = [$data] unless ( ref $data );
$res->{$id}->{$_} = $r->{$_} foreach (@$data);
$res{$id}->{$_} = $r->{$_} foreach (@$data);
}
else {
$res->{$id} = $r;
$res{$id} = $r;
}
}
return $res;
return \%res;
}
sub _col {
Expand Down

0 comments on commit 4250a0c

Please sign in to comment.