couchdb-update/ document
exn: couchdb?
exn: couchdb: conflict?
exn: couchdb: not-found?
Version: 5.2


Jan Dvorak <>

CouchDB client for Racket.

 (require (planet mordae/couchdb:1:7))
Most functions in this module can raise exn:couchdb? exceptions.
There are two special ones, that you might want to handle separately, they are exn:couchdb:conflict? which is raised when document to be modified have been altered by another client and exn:couchdb:not-found? which is raised when given document simply does not exist.

(couchdb-connect [#:host host    
  #:port port    
  #:user user    
  #:password password])  couchdb-server?
  host : string? = "localhost"
  port : exact-nonnegative-integer? = 5984
  user : (or/c string? #f) = #f
  password : (or/c string? #f) = #f
Creates CouchDB server connection information.

In reality, this does not connect anywhere. Provided options are stored in newly created couchdb-server? structure, which is then used for the purpose of URL construction.

(couchdb-server? value)  boolean?
  value : any/c
Determines if given value is a CouchDB server information returned by couchdb-connect.

(couchdb-db server name)  couchdb-database?
  server : couchdb-server?
  name : string?
Creates database connection structure.

Result of this function is used in all database-local queries. It contains both the server and database name, which are used in URL construction.

(couchdb-database? value)  boolean?
  value : any/c
Determines if given value is a CouchDB database returned by couchdb-db.

(couchdb-info server-or-db)  jsexpr?
  server-or-db : (or/c couchdb-server? couchdb-database?)
Returns information about server or database.

(couchdb-all-dbs server)  jsexpr?
  server : couchdb-server?
Returns list with names of all databases present on the server.

(couchdb-get db    
  [#:rev rev    
  #:open-revs open-revs    
  #:revs-info? revs-info?    
  #:conflicts? conflicts?])  jsexpr?
  db : couchdb-database?
  id : string?
  rev : (or/c string? (symbols 'current)) = 'current
  open-revs : 
(or/c (symbols 'all 'current)
      (listof string?))
 = 'current
  revs-info? : boolean? = #f
  conflicts? : boolean? = #f
Retrieves specified document from given CouchDB database.

Consult CouchDB documentation for information on keyword arguments.

(couchdb-put db document)  jsexpr?
  db : couchdb-database?
  document : jsexpr?
Stores specified document in given CouchDB database.

(couchdb-update/document db    
  update-fn)  jsexpr?
  db : couchdb-database?
  document : jsexpr?
  update-fn : (-> jsexpr? jsexpr?)
Updates given document using the update-fn and then puts it to the database.

If put fails with exn:couchdb:conflict?, everything is repeated with current version of the document until put succeeds or raises a different exception.

(couchdb-update db id update-fn)  jsexpr?
  db : couchdb-database?
  id : string?
  update-fn : (-> jsexpr? jsexpr?)
Same as couchdb-update/document, but document is retrieved by given id first.

(couchdb-delete db document)  jsexpr?
  db : couchdb-database?
  document : jsexpr?
Deletes specified document from the CouchDB database.

Deletes given database from the server.

(couchdb-view db    
  [#:include-docs? include-docs?    
  #:key key    
  #:startkey startkey    
  #:startkey-docid startkey-docid    
  #:endkey endkey    
  #:endkey-docid endkey-docid    
  #:limit limit    
  #:stale stale    
  #:descending? descending?    
  #:skip skip    
  #:group? group    
  #:group-level group-level    
  #:reduce? reduce?    
  #:inclusive-end? inclusive-end?    
  #:update-seq? update-seq?])  jsexpr?
  db : couchdb-database?
  view : (list/c string? string?)
  include-docs? : boolean? = #f
  key : (or/c jsexpr? void?) = (void)
  startkey : (or/c jsexpr? void?) = (void)
  startkey-docid : (or/c jsexpr? void?) = (void)
  endkey : (or/c jsexpr? void?) = (void)
  endkey-docid : (or/c jsexpr? void?) = (void)
  limit : (or/c exact-nonnegative-integer? void?) = (void)
  stale : (or/c (symbols 'ok 'update-after) void?) = (void)
  descending? : boolean? = #f
  skip : exact-nonnegative-integer? = 0
  group : boolean? = #f
  group-level : (or/c exact-nonnegative-integer? void?) = (void)
  reduce? : (or/c boolean? void?) = (void)
  inclusive-end? : boolean? = #t
  update-seq? : boolean? = #f
Queries a stored view.

Consult CouchDB documentation for information on keyword arguments.

(exn:couchdb? value)  boolean?
  value : any/c
Generic CouchDB exception.

(exn:couchdb:conflict? value)  boolean?
  value : any/c
Revision conflict exception.
(exn:couchdb:not-found? value)  boolean?
  value : any/c
Document not found exception.