/usr/share/perl5/Catmandu/Store/MongoDB/Searcher.pm is in libcatmandu-store-mongodb-perl 0.0501-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | package Catmandu::Store::MongoDB::Searcher;
use Catmandu::Sane;
our $VERSION = '0.0501';
use Moo;
use namespace::clean;
with 'Catmandu::Iterable';
has bag => (is => 'ro', required => 1);
has query => (is => 'ro', required => 1);
has start => (is => 'ro', required => 1);
has limit => (is => 'ro', required => 1);
has total => (is => 'ro');
has sort => (is => 'ro');
has fields => (is => 'ro');
sub generator {
my ($self) = @_;
sub {
state $cursor = do {
my $c = $self->bag->collection->find($self->query);
$c->fields($self->fields) if defined $self->fields;
# limit is unused because the perl driver doesn't expose batchSize
$c->limit($self->total) if defined $self->total;
$c->sort($self->sort) if defined $self->sort;
$c->immortal(1);
$c;
};
$cursor->next;
};
}
sub slice { # TODO constrain total?
my ($self, $start, $total) = @_;
$start //= 0;
$self->new(
bag => $self->bag,
query => $self->query,
start => $self->start + $start,
limit => $self->limit,
total => $total,
sort => $self->sort,
fields => $self->fields,
);
}
sub count { # TODO constrain on start, total?
my ($self) = @_;
$self->bag->collection->count($self->query);
}
1;
|