rlx-design(3) -- design document commands
=========================================

## SYNOPSIS

Commands for working with design documents.

Design documents are stored in a directory with each function as an individual file. This is considered preferable to writing functions as JSON strings and alleviates the need to escape quotes and newlines when writing design document functions.

When saving design documents all functions are serialized in to a single JSON document which is then sent to a server, use the `design print` command to inspect the serialized representation of a design document.

## DESIGN COMMANDS

Design commands require that a server and database are selected.

* `design ls [name]`:

Lists *local* design documents. If *name* is not specified the design document names (for the currently selected server and database) are printed otherwise all the files for the design document identified by *name* are printed.

* `design add [name]`:

Creates the local directory structure for the named design document, if the named design document already exists then this command will have no effect.

* `design rm [name] [id]`:

Deletes the directory for the local design document identified by *name*. If the *id* option is specified then it refers to a function file, if a function file exists matching the *id* then only that file is deleted. You do not need to specify a file extension for *id*.

It is possible that the *id* option will match multiple files, for example, if you have a show and a list function that have the same *id*. Under this situation a select menu enables you to choose which function file to delete.

You may also delete groups of functions using the plural form for the group, for example, to delete all show functions use *shows* as the *id*.

This command prompts for confirmation before execution.

* `design print [name]`:

Print the JSON representation of a local design document.

* `design show [name] [id]`:

Create or edit a show function for the design document identified by *name*. The *id* option is required and specifies the field name within *shows* when the design document is serialized.

* `design update [name] [id]`:

Create or edit an update function for the design document identified by *name*. The *id* option is required and specifies the field name within *updates* when the design document is serialized.

* `design filter [name] [id]`:

Create or edit a filter function for the design document identified by *name*. The *id* option is required and specifies the field name within *filters* when the design document is serialized.

* `design list [name] [id]`:

Create or edit a list function for the design document identified by *name*. The *id* option is required and specifies the field name within *lists* when the design document is serialized.

* `design validate [name]`:

Create or edit a validation function for the design document identified by *name*. The contents of the validation function file are assigned to the `validate_doc_update` field of the design document.

* `design info [name]`:

Prints information for the named design document using the currently selected server and database.

* `design compact [view]`:

Compact the named view on the currently selected database.

## QUERY COMMANDS

Queries are documents that describe the parameters for a view query. Query commands require that a server and database are selected.

Query document names must only contain alphanumeric characters and hyphens. Query documents are saved with a json file extension but do not include the file extension when referencing query documents.

* `query add [name]`:

Creates a named query from a template and opens the query document in the editor, save the query document to run the query later. If the named query exists this command defers to `query edit`.

* `query edit [name]`:

Edit an existing named query.

* `query ls`:

List saved query documents for the current server and database.

* `query rm [name]`:

Delete an existing named query.

* `query all [name]`:

Run the named query against the all documents view for the currently selected server and database.

* `query run [name] [design] [view]`:

Run the named query against the specified design document and view for the currently selected server and database.

## FILES

### Design Documents

Design documents are stored in `${rlx_user}/design` organized by server hostname and database name.

### Query Documents

Query documents are stored in `${rlx_user}/query` organized by server hostname and database name.

## BUGS

**rlx** is written in bash and depends upon `bash >= 4.2`.

## COPYRIGHT

**rlx** is copyright (c) 2013 muji <http://xpm.io>

## SEE ALSO

rlx(1), couchdb(3)
