(ad-hoc-view db [language view-server-fns] & [query-params-map])
One-off queries (i.e. views you don't want to save in the CouchDB database). Ad-hoc views should be used only during development. Also takes an optional map for querying options (see: http://wiki.apache.org/couchdb/HTTP_view_API).
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
One-off queries (i.e. views you don't want to save in the CouchDB database). Ad-hoc views should be used only during development. Also takes an optional map for querying options (see: http://wiki.apache.org/couchdb/HTTP_view_API). When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(all-databases db)
Returns a list of all databases on the CouchDB server.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns a list of all databases on the CouchDB server. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(all-documents db & [query-params-map post-data-map :as args])
Returns the meta (_id and _rev) of all documents in a database. By adding the key ':include_docs' with a value of true to the optional query params map you can also get the full documents, not just their meta. Also takes an optional second map of {:keys [keys]} to be POSTed. (see: http://wiki.apache.org/couchdb/HTTP_view_API).
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns the meta (_id and _rev) of all documents in a database. By adding the key ':include_docs' with a value of true to the optional query params map you can also get the full documents, not just their meta. Also takes an optional second map of {:keys [keys]} to be POSTed. (see: http://wiki.apache.org/couchdb/HTTP_view_API). When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(bulk-update db documents & {:as options})
Takes a sequential collection of documents (maps) and inserts or updates (if "_id" and "_rev" keys are supplied in a document) them with in a single request.
Optional keyword args may be provided, and are sent along with the documents (e.g. for "all-or-nothing" semantics, etc).
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Takes a sequential collection of documents (maps) and inserts or updates (if "_id" and "_rev" keys are supplied in a document) them with in a single request. Optional keyword args may be provided, and are sent along with the documents (e.g. for "all-or-nothing" semantics, etc). When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(change-agent db & {:as opts})
Returns an agent whose state will very to contain events emitted by the _changes feed of the specified database.
Users are expected to attach functions to the agent using
add-watch
in order to be notified of changes. The
returned change agent is entirely 'managed', with
start-changes
and stop-changes
controlling its operation
and sent actions. If you send actions to a change agent,
bad things will likely happen.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns an agent whose state will very to contain events emitted by the _changes feed of the specified database. Users are expected to attach functions to the agent using `add-watch` in order to be notified of changes. The returned change agent is entirely 'managed', with `start-changes` and `stop-changes` controlling its operation and sent actions. If you send actions to a change agent, bad things will likely happen. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(changes db
&
{:keys [since limit descending feed heartbeat timeout filter
include_docs style]
:as opts})
Returns a lazy seq of the rows in _changes, as configured by the given options.
If you want to react to change notifications, you should probably use change-agent
.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns a lazy seq of the rows in _changes, as configured by the given options. If you want to react to change notifications, you should probably use `change-agent`. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(changes-running? change-agent)
Returns true only if the given change agent has been started
(using start-changes
) and is delivering changes to
attached watches.
Returns true only if the given change agent has been started (using `start-changes`) and is delivering changes to attached watches.
(configure-view-server db
exec-string
&
{:keys [language] :or {language "clojure"}})
Sets the query server exec string for views written in the specified :language ("clojure" by default). This is intended to be a REPL convenience function; see the Clutch README for more info about setting up CouchDB to be Clutch-view-server-ready in general terms.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Sets the query server exec string for views written in the specified :language ("clojure" by default). This is intended to be a REPL convenience function; see the Clutch README for more info about setting up CouchDB to be Clutch-view-server-ready in general terms. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(copy-document db src dest)
Copies the provided document (or the document with the given string id) to the given new id. If the destination id identifies an existing document, then a document map (with up-to-date :_id and :_rev slots) must be provided as a destination argument to avoid a 409 Conflict.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Copies the provided document (or the document with the given string id) to the given new id. If the destination id identifies an existing document, then a document map (with up-to-date :_id and :_rev slots) must be provided as a destination argument to avoid a 409 Conflict. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(couch url)
(couch url meta)
Returns an instance of an implementation of CouchOps. (EXPERIMENTAL!)
Returns an instance of an implementation of CouchOps. (EXPERIMENTAL!)
(couchdb-info db)
Returns information about a CouchDB instance.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns information about a CouchDB instance. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
Defines side-effecting operations on a CouchDB database. All operations return the CouchDB database reference — with the return value from the underlying clutch function added to its :result metadata — for easy threading and reduction usage. (EXPERIMENTAL!)
Defines side-effecting operations on a CouchDB database. All operations return the CouchDB database reference — with the return value from the underlying clutch function added to its :result metadata — for easy threading and reduction usage. (EXPERIMENTAL!)
(assoc! this id document)
PUTs a document into CouchDB. Equivalent to (conj! couch [id document]).
PUTs a document into CouchDB. Equivalent to (conj! couch [id document]).
(conj! this document)
PUTs a document into CouchDB. Accepts either a document map (using an :_id value if present as the document id), or a vector/map entry consisting of a [id document-map] pair.
PUTs a document into CouchDB. Accepts either a document map (using an :_id value if present as the document id), or a vector/map entry consisting of a [id document-map] pair.
(create! this)
Ensures that the database exists, and returns the database's meta info.
Ensures that the database exists, and returns the database's meta info.
(dissoc! this id-or-doc)
DELETEs a document from CouchDB. Uses a given document map's :_id and :_rev if provided; alternatively, if passed a string, will blindly attempt to delete the current revision of the corresponding document.
DELETEs a document from CouchDB. Uses a given document map's :_id and :_rev if provided; alternatively, if passed a string, will blindly attempt to delete the current revision of the corresponding document.
(create-database db)
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(database-info db)
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(delete-attachment db document file-name)
Deletes an attachemnt from a document.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Deletes an attachemnt from a document. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(delete-database db)
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(delete-document db document)
Takes a document and deletes it from the database.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Takes a document and deletes it from the database. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(dissoc-meta doc)
dissoc'es the :_id and :_rev slots from the provided map.
dissoc'es the :_id and :_rev slots from the provided map.
(document-exists? db id)
Returns true if a document with the given key exists in the database.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns true if a document with the given key exists in the database. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(get-attachment db doc-or-id attachment-name)
Returns an InputStream reading the named attachment to the specified/provided document or nil if the document or attachment does not exist.
Hint: use the copy or to-byte-array fns in c.c.io to easily redirect the result.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns an InputStream reading the named attachment to the specified/provided document or nil if the document or attachment does not exist. Hint: use the copy or to-byte-array fns in c.c.io to easily redirect the result. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(get-database db)
Returns a database meta information if it already exists else creates a new database and returns the meta information for the new database.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns a database meta information if it already exists else creates a new database and returns the meta information for the new database. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(get-document db id & {:as get-params})
Returns the document identified by the given id. Optional CouchDB document API query parameters (rev, attachments, may be provided as keyword arguments.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Returns the document identified by the given id. Optional CouchDB document API query parameters (rev, attachments, may be provided as keyword arguments. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(get-view db
design-document
view-key
&
[query-params-map post-data-map :as args])
Get documents associated with a design document. Also takes an optional map for querying options, and a second map of {:key [keys]} to be POSTed. (see: http://wiki.apache.org/couchdb/HTTP_view_API).
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Get documents associated with a design document. Also takes an optional map for querying options, and a second map of {:key [keys]} to be POSTed. (see: http://wiki.apache.org/couchdb/HTTP_view_API). When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(put-attachment db document data & {:keys [filename mime-type data-length]})
Updates (or creates) the attachment for the given document. data
can be a string path
to a file, a java.io.File, a byte array, or an InputStream.
If data
is a byte array or InputStream, you must include the following otherwise-optional
kwargs:
:filename — name to be given to the attachment in the document
:mime-type — type of attachment data
These are derived from a file path or File if not provided. (Mime types are derived from filename extensions; see com.ashafa.clutch.utils/get-mime-type for determining mime type yourself from a File object.)
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Updates (or creates) the attachment for the given document. `data` can be a string path to a file, a java.io.File, a byte array, or an InputStream. If `data` is a byte array or InputStream, you _must_ include the following otherwise-optional kwargs: :filename — name to be given to the attachment in the document :mime-type — type of attachment data These are derived from a file path or File if not provided. (Mime types are derived from filename extensions; see com.ashafa.clutch.utils/get-mime-type for determining mime type yourself from a File object.) When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(put-document db document & {:keys [id attachments request-params]})
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(replicate-database srcdb tgtdb)
Takes two arguments (a source and target for replication) which could be a string (name of a database in the default Clutch configuration) or a map that contains a least the database name (':name' keyword, map is merged with default Clutch configuration) and reproduces all the active documents in the source database on the target databse.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Takes two arguments (a source and target for replication) which could be a string (name of a database in the default Clutch configuration) or a map that contains a least the database name (':name' keyword, map is merged with default Clutch configuration) and reproduces all the active documents in the source database on the target databse. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(save-design-document db
fn-type
design-document-name
[language view-server-fns])
Create/update a design document containing functions used for database queries/filtering/validation/etc.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Create/update a design document containing functions used for database queries/filtering/validation/etc. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(save-filter db & args)
Create a filter for use with CouchDB change notifications API.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Create a filter for use with CouchDB change notifications API. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(save-view db & args)
Create or update a design document containing views used for database queries.
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Create or update a design document containing views used for database queries. When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
(start-changes change-agent)
Starts the flow of changes through the given change-agent.
All of the options provided to change-agent
are used to
configure the underlying _changes feed.
Starts the flow of changes through the given change-agent. All of the options provided to `change-agent` are used to configure the underlying _changes feed.
(stop-changes change-agent)
Stops the flow of changes through the given change-agent.
Change agents can be restarted with start-changes
.
Stops the flow of changes through the given change-agent. Change agents can be restarted with `start-changes`.
(update-document db document & [mod & args])
Takes document and a map and merges it with the original. When a function and a vector of keys are supplied as the second and third argument, the value of the keys supplied are updated with the result of the function of their values (see: #'clojure.core/update-in).
When used within the dynamic scope of with-db
, the initial db
argument is automatically provided.
Takes document and a map and merges it with the original. When a function and a vector of keys are supplied as the second and third argument, the value of the keys supplied are updated with the result of the function of their values (see: #'clojure.core/update-in). When used within the dynamic scope of `with-db`, the initial `db` argument is automatically provided.
A very 'high' unicode character that can be used as a wildcard suffix when querying views.
A very 'high' unicode character that can be used as a wildcard suffix when querying views.
(with-db database & body)
Takes a URL, database name (useful for localhost only), or an instance of com.ashafa.clutch.utils.URL. That value is used to configure the subject of all of the operations within the dynamic scope of body of code.
Takes a URL, database name (useful for localhost only), or an instance of com.ashafa.clutch.utils.URL. That value is used to configure the subject of all of the operations within the dynamic scope of body of code.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close