NAME
Net::CouchDb::Document - Represent a CouchDb document
SYNOPSIS
Provides an object oriented interface to the CouchDb REST/JSON API.
METHODS
new([$id][, $fields[, $database]])
Creates a new instance of a document in memory, all parameters are optional.
If an ID is not provided one will be generated automatically by CoudhDb when the document is created.
A hash reference is expected for the fields.
If the database is provided then it will be used for the ->create
and ->update
methods.
Note: The new
method merely creates an instance of the object; it does not touch the database.
id
Getter/setter for the ID.
rev
Getter/setter for the revision.
uri
Return a URI to this document. Requires document to have been created.
create
Create this document (using the database specified in new
).
If an ID has not been previously supplied CouchDb will create one and the object will be updated to reflect this.
update
Update this document (using the database specified in new
).
attach([$name[, $file]])
List, add or retrieve attachments.
With no parameters returns a list of attached files.
With a name returns a Net::CouchDb::Attach object.
With file specified as well passes the file parameter to the add
method of Net::CouchDb::Attach.
Anything else
This object provides an autoloaded method for any parameter that is set, therefore any field can be set like so:
$doc->foo = "bar";
Because id
, rev
, uri
, attach
, create
and update
are taken by the above methods you should use syntax like:
$doc->{create} = 1;
If you want to give parameters those names.
AUTHOR
David Leadbeater, <dgl at dgl dot cx>
COPYRIGHT & LICENSE
Copyright 2007 David Leadbeater, all rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.