1 package WebPAC::Output::CouchDB;
6 use base qw/WebPAC::Common WebPAC::Output Class::Accessor/;
7 __PACKAGE__->mk_accessors(qw(
13 use Data::Dump qw/dump/;
19 WebPAC::Output::CouchDB - feed data into CouchDB
31 my $log = $self->_get_logger;
35 my $u = URI->new( $self->url );
37 my $cdb = Net::CouchDb->new(
38 host => $u->host || "localhost",
39 port => $u->port || 5984,
42 my $database = $self->database || 'webpac2';
44 $log->info("CouchDB database $database info ", dump( $cdb->server_info ) );
46 $cdb->debug( $self->debug );
47 eval { $cdb->delete_db( $self->database ) };
48 $cdb->create_db( $self->database );
49 $self->{_cdb} = $cdb->db( $self->database );
57 Adds one entry to database.
68 my $log = $self->_get_logger;
70 $id = $self->input . '-' . $id if $self->input;
72 my $doc = Net::CouchDb::Document->new( $id, $ds );
73 $self->{_cdb}->put( $doc );
87 my $log = $self->_get_logger();
96 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
98 =head1 COPYRIGHT & LICENSE
100 Copyright 2009 Dobrica Pavlinusic, All Rights Reserved.
102 This program is free software; you can redistribute it and/or modify it
103 under the same terms as Perl itself.
107 1; # End of WebPAC::Output::CouchDB