AnyEvent-CouchDB
view release on metacpan or search on metacpan
lib/AnyEvent/CouchDB.pm view on Meta::CPAN
=head3 $db = couchdb($name_or_uri);
This function will construct an L<AnyEvent::CouchDB::Database> object for you.
If you only give it a name, it'll assume that the CouchDB server is at
L<http://localhost:5984/>. You may also give it a full URL to a CouchDB
database to connect to.
This function is also exported by default.
=head2 Object Construction
=head3 $couch = AnyEvent::CouchDB->new([ $uri ])
This method will instantiate an object that represents a CouchDB server.
By default, it connects to L<http://localhost:5984/>, but you may explicitly
give it another URL if you want to connect to a CouchDB server on another
server or a non-default port.
=head3 $db = $couch->db($name)
This method takes a name and returns an L<AnyEvent::CouchDB::Database> object.
This is the object that you'll use to work with CouchDB documents.
=head2 Queries and Actions
=head3 $cv = $couch->all_dbs()
This method requests an arrayref that contains the names of all the databases
hosted on the current CouchDB server. It returns an AnyEvent condvar that
you'll be expected to call C<recv> on to get the data back.
=head3 $cv = $couch->info()
This method requests a hashref of info about the current CouchDB server and
returns a condvar that you should call C<recv> on. The hashref that's returned
looks like this:
{
couchdb => 'Welcome',
version => '0.7.3a658574'
}
=head3 $cv = $couch->config()
This method requests a hashref of info regarding the configuration of the
current CouchDB server. It returns a condvar that you should call C<recv> on.
=head3 $cv = $couch->replicate($source, $target, [ \%options ])
This method requests that a C<$source> CouchDB database be replicated to a
C<$target> CouchDB database. To represent a local database, pass in just
the name of the database. To represent a remote database, pass in the
URL to that database. Note that both databases must already exist for
the replication to work. To create a continuous replication, set the
B<continuous> option to true.
B<Examples>:
# local to local
$couch->replicate('local_db', 'local_db_backup')->recv;
# local to remote
$couch->replicate('local_db', 'http://elsewhere/remote_db')->recv
# remote to local
$couch->replicate('http://elsewhere/remote_db', 'local_db')->recv
# local to remote with continuous replication
$couch->replicate('local_db', 'http://elsewhere/remote_db', {continuous => 1})->recv
As usual, this method returns a condvar that you're expected to call C<recv> on.
Doing this will return a hashref that looks something like this upon success:
{
history => [
{
docs_read => 0,
docs_written => 0,
end_last_seq => 149,
end_time => "Thu, 17 Jul 2008 18:08:13 GMT",
missing_checked => 44,
missing_found => 0,
start_last_seq => 0,
start_time => "Thu, 17 Jul 2008 18:08:13 GMT",
},
],
ok => bless(do { \(my $o = 1) }, "JSON::XS::Boolean"),
session_id => "cac3c6259b452c36230efe5b41259c04",
source_last_seq => 149,
}
=head1 SEE ALSO
=head2 Scripts
=over 4
=item L<couchdb-push>
Push documents from the filesystem to CouchDB
=back
=head2 Related Modules
L<AnyEvent::CouchDB::Database>, L<AnyEvent::CouchDB::Exceptions>,
L<AnyEvent::HTTP>, L<AnyEvent>, L<Exception::Class>
=head2 Other CouchDB-related Perl Modules
=head3 Client Libraries
L<Net::CouchDb>,
L<CouchDB::Client>,
L<POE::Component::CouchDB::Client>,
L<DB::CouchDB>
=head3 View Servers
L<CouchDB::View> - This lets you write your map/reduce functions in Perl
( run in 1.010 second using v1.01-cache-2.11-cpan-39bf76dae61 )