App-RecordStream

 view release on metacpan or  search on metacpan

lib/App/RecordStream/Operation/frommongo.pm  view on Meta::CPAN

  $this->{'QUERY'}          = $json->decode($query);
}

sub wants_input {
  return 0;
}

sub stream_done {
  my $this = shift;

  my $cursor = $this->get_query();

  while (my $object = $cursor->next()) {
    $this->push_record($object);
  }
}

sub get_query {
  my $this = shift;

  # this momoization is really just a hook for tests
  if ($this->{'CURSOR'}) {
    return $this->{'CURSOR'};

tests/RecordStream/Operation/frommongo.pm  view on Meta::CPAN

};

my $keeper = App::RecordStream::Test::OperationHelper::Keeper->new();
my $op = App::RecordStream::Operation::frommongo->new(
  [qw(--host localhost --name my_db --user foo --pass bar --query {} --collection zip)],
  $keeper
);

ok($op, "Frommongo initialized");

my $cursor = MockCursor->new([
  {foo => 'bar',  zip => 2},
  {zap => 'blah', car => 8},
]);

$op->{'CURSOR'} = $cursor;

$op->finish();

my $solution = [
  {foo => 'bar',  zip => 2},
  {zap => 'blah', car => 8},
];

is_deeply($keeper->get_records(), $solution, "Records from Cursor are output");



( run in 0.237 second using v1.01-cache-2.11-cpan-4d50c553e7e )