Permalink
Browse files

Implement simple searching.

  • Loading branch information...
1 parent ba4a18f commit 5fa8c422bbe0c79a0905e3932b8db234b6746516 @rafl committed Mar 15, 2009
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/KiokuDB/Backend/MongoDB.pm
@@ -11,6 +11,7 @@ with qw/
KiokuDB::Backend::Serialize::MongoDB
KiokuDB::Backend::Role::Clear
KiokuDB::Backend::Role::Scan
+ KiokuDB::Backend::Role::Query::Simple
/;
has [qw/database_name collection_name/] => (
@@ -96,6 +97,17 @@ sub all_entries {
});
}
+sub simple_search {
+ my ($self, $proto) = @_;
+ my $cursor = $self->collection->query($proto);
+ return Data::Stream::Bulk::Callback->new(sub {
+ if (my $obj = $cursor->next) {
+ return [$obj];
+ }
+ return;
+ });
+}
+
__PACKAGE__->meta->make_immutable;
1;

0 comments on commit 5fa8c42

Please sign in to comment.