1 package MojoFacets::Import::CouchDB;
9 use Data::Dump qw(dump);
13 __PACKAGE__->attr('path');
14 __PACKAGE__->attr('full_path');
19 my $path = $self->path;
21 # we could use Mojo::JSON here, but it's too slow
22 # $data = from_json read_file $path;
23 my $url = read_file $self->full_path;
26 warn "# CouchDB URL: $url";
28 my $json = Mojo::Client->new->get( "$url/_all_docs?include_docs=true" )->res->json;
32 if ( ref $json->{rows} eq 'ARRAY' ) {
33 foreach my $doc ( @{$json->{rows}} ) {
34 push @{ $data->{items} }, $doc->{doc};