NAME

Couch::DB::Design - handle design documents

INHERITANCE

Couch::DB::Design
  is a Couch::DB::Document

SYNOPSIS

DESCRIPTION

In CouchDB, design documents provide the main interface for building a CouchDB application. The design document defines the views used to extract information from CouchDB through one or more views.

Design documents behave just like your own documents, but occupy the _design/ namespace in your database. A bunch of the methods are therefore exactly the same as the methods in base-class Couch::DB::Document.

Extends "DESCRIPTION" in Couch::DB::Document.

METHODS

Extends "METHODS" in Couch::DB::Document.

Constructors

Extends "Constructors" in Couch::DB::Document.

Couch::DB::Design->new(%options)
-Option --Defined in         --Default
 batch    Couch::DB::Document  from database
 content  Couch::DB::Document  undef
 db       Couch::DB::Document  undef
 id       Couch::DB::Document  undef
 local    Couch::DB::Document  false
batch => BOOLEAN
content => DATA
db => Couch::DB::Database-object
id => ID
local => BOOLEAN

Accessors

Extends "Accessors" in Couch::DB::Document.

$obj->batch()

Inherited, see "Accessors" in Couch::DB::Document

$obj->couch()

Inherited, see "Accessors" in Couch::DB::Document

$obj->db()

Inherited, see "Accessors" in Couch::DB::Document

$obj->id()

Inherited, see "Accessors" in Couch::DB::Document

Content

Extends "Content" in Couch::DB::Document.

$obj->isDeleted()

Inherited, see "Content" in Couch::DB::Document

$obj->isLocal()

Inherited, see "Content" in Couch::DB::Document

$obj->latest()

Inherited, see "Content" in Couch::DB::Document

$obj->rev()

Inherited, see "Content" in Couch::DB::Document

$obj->revision($rev)

Inherited, see "Content" in Couch::DB::Document

$obj->revisions()

Inherited, see "Content" in Couch::DB::Document

Document details

Extends "Document details" in Couch::DB::Document.

$obj->conflicts()

Inherited, see "Document details" in Couch::DB::Document

$obj->deletedConflicts()

Inherited, see "Document details" in Couch::DB::Document

$obj->revisionInfo($revision)

Inherited, see "Document details" in Couch::DB::Document

$obj->revisionsInfo()

Inherited, see "Document details" in Couch::DB::Document

$obj->updateSequence()

Inherited, see "Document details" in Couch::DB::Document

Document in the database

All methods below are inherited from standard documents. Their call URI differs, but their implementation is the same. On the other hand: they add interpretation on fields which do not start with '_'.

Extends "Document in the database" in Couch::DB::Document.

$obj->appendTo($doc, %options)
[CouchDB API "COPY /{db}/_design/{ddoc}"]
$obj->cloneInto($doc, %options)
[CouchDB API "COPY /{db}/_design/{ddoc}"]
$obj->create(\%data, %options)

Create a new design document. Design documents do not use generated ids, so: you have to have specified one with new(id). Therefore, this method is equivalent to update().

-Option--Defined in         --Default
 batch   Couch::DB::Document  new(batch)
batch => BOOLEAN
$obj->delete(%options)
[CouchDB API "DELETE /{db}/_design/{ddoc}"]
$obj->details(%options)
[CouchDB API "GET /{db}/_design/{ddoc}/_info", UNTESTED]

Obtains information about the specified design document, including the index, index size and current status of the design document and associated index information.

$obj->exists(%option)
[CouchDB API "HEAD /{db}/_design/{ddoc}"]

Returns the HTTP Headers containing a minimal amount of information about the specified design document.

$obj->get(%options)
[CouchDB API "GET /{db}/_design/{ddoc}"]
$obj->update(\%data, %options)
[CouchDB API "PUT /{db}/_design/{ddoc}"]

Options filters, lists, shows, and updates are HASHes which map names to fragments of code written in programming language language (usually erlang or javascript).

Options lists, show, and rewrites (query redirection) are deprecated since 3.0, and are removed from 4.0.

-Option--Defined in         --Default
 batch   Couch::DB::Document  new(batch)
batch => BOOLEAN

Attachments

Extends "Attachments" in Couch::DB::Document.

$obj->attDelete($name, %options)
[CouchDB API "DELETE /{db}/_design/{ddoc}/{attname}" ]
$obj->attExists($name, %options)
[CouchDB API "HEAD /{db}/_design/{ddoc}/{attname}"]
$obj->attInfo($name)

Inherited, see "Attachments" in Couch::DB::Document

$obj->attLoad($name, %options)
[CouchDB API "GET /{db}/_design/{ddoc}/{attname}" ]
$obj->attSave($name, $data, %options)
[CouchDB API "PUT /{db}/_design/{ddoc}/{attname}" ]

-Option--Defined in         --Default
 type    Couch::DB::Document  application/octet-stream
type => IANA-MediaType
$obj->attachment($name)

Inherited, see "Attachments" in Couch::DB::Document

$obj->attachments()

Inherited, see "Attachments" in Couch::DB::Document

Indexes

$obj->createIndex(\%filter, %options)
[CouchDB API "POST /{db}/_index", UNTESTED]

Create/confirm an index on the database. When you like a generated design document name, you can use Couch::DB::Database::createIndex().

$obj->deleteIndex($index, %options)
[CouchDB API "DELETE /{db}/_index/{designdoc}/json/{name}", UNTESTED]

Remove an index from this design document.

$obj->indexDetails($index, %options)
[CouchDB API "GET /{db}/_design/{ddoc}/_search_info/{index}", UNTESTED]

Returns metadata for the specified search index.

$obj->indexFind($index, %options)
[CouchDB API "GET /{db}/_design/{ddoc}/_search/{index}", UNTESTED]

Executes a search request against the named $index.

When you have used include_docs, then the documents can be found in $result->values->{docs}, not {rows}.

-Option--Default
 search  {}
search => HASH

The search query.

Views

$obj->viewSearch( $view, [\%search|\@%search), %options] )
[CouchDB API "GET /{db}/_design/{ddoc}/_view/{view}", UNTESTED]
[CouchDB API "POST /{db}/_design/{ddoc}/_view/{view}", UNTESTED]
[CouchDB API "POST /{db}/_design/{ddoc}/_view/{view}/queries", UNTESTED]
[CouchDB API "GET /{db}/_partition/{partition}/_design/{ddoc}/_view/{view}", UNTESTED]

Executes the specified view function.

This work is handled in Couch::DB::Database::search(). See that method for %options and results.

Functions

$obj->applyUpdate( $function, [$doc|$docid|undef, %options] )
[CouchDB API "POST /{db}/_design/{ddoc}/_update/{func}", UNTESTED]
[CouchDB API "POST /{db}/_design/{ddoc}/_update/{func}/{docid}", UNTESTED]

See what the update function would change. The update $function is run on a document, specified by id or object. By default or explicit undef, a null (missing) document will be used.

$obj->list($function, $view, %options)
[CouchDB API "GET /{db}/_design/{ddoc}/_list/{func}/{view}", deprecated 3.0, removed 4.0, UNTESTED]
[CouchDB API "POST /{db}/_design/{ddoc}/_list/{func}/{view}", deprecated 3.0, removed 4.0, UNTESTED]
[CouchDB API "GET /{db}/_design/{ddoc}/_list/{func}/{other-ddoc}/{view}", deprecated 3.0, removed 4.0, UNTESTED]
[CouchDB API "POST /{db}/_design/{ddoc}/_list/{func}/{other-ddoc}/{view}", deprecated 3.0, removed 4.0, UNTESTED]

Executes a list function against the view.

-Option   --Default
 view_ddoc  undef
view_ddoc => $ddoc|$ddocid

When the $view resides in a differen design.

$obj->show( $function, [$doc|$docid|undef, %options] )
[CouchDB API "GET /{db}/_design/{ddoc}/_show/{func}", deprecated 3.0, removed 4.0, UNTESTED]
[CouchDB API "POST /{db}/_design/{ddoc}/_show/{func}", deprecated 3.0, removed 4.0, UNTESTED]
[CouchDB API "GET /{db}/_design/{ddoc}/_show/{func}/{docid}", deprecated 3.0, removed 4.0, UNTESTED]
[CouchDB API "POST /{db}/_design/{ddoc}/_show/{func}/{docid}", deprecated 3.0, removed 4.0, UNTESTED]

Apply show $function on the document, as specified by id or object. By default or explicit undef, a null document will be used.

SEE ALSO

This module is part of Couch-DB distribution version 0.006, built on September 09, 2024. Website: http://perl.overmeer.net/CPAN/

LICENSE

Copyrights 2024 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/