CouchDB
CouchDB client for Racket.
(require (planet mordae/couchdb:1:9)) |
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
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
(couchdb-db server name) → couchdb-database? server : couchdb-server? name : string?
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
(couchdb-info server-or-db) → jsexpr? server-or-db : (or/c couchdb-server? couchdb-database?)
(couchdb-all-dbs server) → jsexpr? server : couchdb-server?
(couchdb-all-docs db) → jsexpr? db : couchdb-database?
(couchdb-uuids server [#:count count]) → (listof string?) server : couchdb-server? count : exact-nonnegative-integer? = 1
(couchdb-get db id [ #: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
Consult CouchDB documentation for information on keyword arguments.
(couchdb-put db document) → jsexpr? db : couchdb-database? document : jsexpr?
(couchdb-update/document db document update-fn) → jsexpr? db : couchdb-database? document : jsexpr? update-fn : (-> jsexpr? jsexpr?)
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?)
(couchdb-delete db document) → jsexpr? db : couchdb-database? document : jsexpr?
(couchdb-delete-db db) → jsexpr? db : couchdb-database?
(couchdb-view db view [ #: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
Consult CouchDB documentation for information on keyword arguments.
(exn:couchdb? value) → boolean? value : any/c
(exn:couchdb:conflict? value) → boolean? value : any/c
(exn:couchdb:not-found? value) → boolean? value : any/c