-
Notifications
You must be signed in to change notification settings - Fork 3
/
manual.scrbl
167 lines (138 loc) · 5.95 KB
/
manual.scrbl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#lang scribble/manual
@require[(planet cce/scheme:4:1/planet)]
@require[(for-label racket net/url)]
@require[(for-label (planet dherman/json:3:0))]
@require[(for-label (this-package-in main))]
@title{CouchDB}
@author{@(author+email "Jan Dvorak" "[email protected]")}
CouchDB client for Racket.
@defmodule/this-package[]
Most functions in this module can raise @racket[exn:couchdb?] exceptions.
There are two special ones, that you might want to handle separately,
they are @racket[exn:couchdb:conflict?] which is raised when document
to be modified have been altered by another client and
@racket[exn:couchdb:not-found?] which is raised when given document
simply does not exist.
@defproc[(couchdb-connect (#:host host string? "localhost")
(#:port port exact-nonnegative-integer? 5984)
(#:user user (or/c string? #f) #f)
(#:password password (or/c string? #f) #f))
couchdb-server?]{
Creates CouchDB server connection information.
In reality, this does not connect anywhere. Provided options are
stored in newly created @racket[couchdb-server?] structure, which
is then used for the purpose of URL construction.
}
@defproc[(couchdb-server? (value any/c)) boolean?]{
Determines if given value is a CouchDB server information returned
by @racket[couchdb-connect].
}
@defproc[(couchdb-db (server couchdb-server?)
(name string?))
couchdb-database?]{
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.
}
@defproc[(couchdb-database? (value any/c)) boolean?]{
Determines if given value is a CouchDB database returned by
@racket[couchdb-db].
}
@defproc[(couchdb-info (server-or-db (or/c couchdb-server? couchdb-database?)))
jsexpr?]{
Returns information about server or database.
}
@defproc[(couchdb-all-dbs (server couchdb-server?))
jsexpr?]{
Returns list with names of all databases present on the server.
}
@defproc[(couchdb-all-docs (db couchdb-database?))
jsexpr?]{
Returns contents of the _all_docs special view that maps all documents in
given database by their ids.
}
@defproc[(couchdb-uuids (server couchdb-server?)
(#:count count exact-nonnegative-integer? 1))
(listof string?)]{
Returns list of server-generated UUIDs.
}
@defproc[(couchdb-get (db couchdb-database?)
(id string?)
(#:rev rev (or/c string? (symbols 'current)) 'current)
(#:open-revs open-revs (or/c (symbols 'all 'current)
(listof string?)) 'current)
(#:revs-info? revs-info? boolean? #f)
(#:conflicts? conflicts? boolean? #f))
jsexpr?]{
Retrieves specified document from given CouchDB database.
Consult @link["http://wiki.apache.org/couchdb/HTTP_Document_API"]{CouchDB
documentation} for information on keyword arguments.
}
@defproc[(couchdb-put (db couchdb-database?)
(document jsexpr?))
jsexpr?]{
Stores specified document in given CouchDB database.
}
@defproc[(couchdb-update/document (db couchdb-database?)
(document jsexpr?)
(update-fn (-> jsexpr? jsexpr?)))
jsexpr?]{
Updates given document using the @racket[update-fn] and then puts it to
the database.
If put fails with @racket[exn:couchdb:conflict?], everything is repeated
with current version of the document until put succeeds or raises a
different exception.
}
@defproc[(couchdb-update (db couchdb-database?)
(id string?)
(update-fn (-> jsexpr? jsexpr?)))
jsexpr?]{
Same as @racket[couchdb-update/document], but document is retrieved by
given id first.
}
@defproc[(couchdb-delete (db couchdb-database?)
(document jsexpr?))
jsexpr?]{
Deletes specified document from the CouchDB database.
}
@defproc[(couchdb-delete-db (db couchdb-database?))
jsexpr?]{
Deletes given database from the server.
}
@defproc[(couchdb-view (db couchdb-database?)
(view (list/c string? string?))
(#:include-docs? include-docs? boolean? #f)
(#:key key (or/c jsexpr? void?) (void))
(#:startkey startkey (or/c jsexpr? void?) (void))
(#:startkey-docid startkey-docid (or/c jsexpr? void?)
(void))
(#:endkey endkey (or/c jsexpr? void?) (void))
(#:endkey-docid endkey-docid (or/c jsexpr? void?) (void))
(#:limit limit (or/c exact-nonnegative-integer? void?)
(void))
(#:stale stale (or/c (symbols 'ok 'update-after) void?)
(void))
(#:descending? descending? boolean? #f)
(#:skip skip exact-nonnegative-integer? 0)
(#:group? group boolean? #f)
(#:group-level group-level
(or/c exact-nonnegative-integer? void?) (void))
(#:reduce? reduce? (or/c boolean? void?) (void))
(#:inclusive-end? inclusive-end? boolean? #t)
(#:update-seq? update-seq? boolean? #f))
jsexpr?]{
Queries a stored view.
Consult @link["http://wiki.apache.org/couchdb/HTTP_view_API"]{CouchDB
documentation} for information on keyword arguments.
}
@defproc[(exn:couchdb? (value any/c)) boolean?]{
Generic CouchDB exception.
}
@defproc[(exn:couchdb:conflict? (value any/c)) boolean?]{
Revision conflict exception.
}
@defproc[(exn:couchdb:not-found? (value any/c)) boolean?]{
Document not found exception.
}
@; vim:set ft=scribble sw=2 ts=2 et: