forked from factor/factor
-
Notifications
You must be signed in to change notification settings - Fork 3
/
driver-docs.factor
283 lines (242 loc) · 8.55 KB
/
driver-docs.factor
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
! Copyright (C) 2009 Your name.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs help.markup help.syntax kernel quotations ;
IN: mongodb.driver
HELP: <mdb-collection>
{ $values
{ "name" "name of the collection" }
{ "collection" "mdb-collection instance" }
}
{ $examples { $unchecked-example "USING: mongodb.driver ;" "\"mycollection\" <mdb-collection> t >>capped 1000000 >>max" "" } }
{ $description "Creates a new mdb-collection instance. Use this to create capped/limited collections." } ;
HELP: <mdb>
{ $values
{ "db" "name of the database to use" }
{ "host" "host name or IP address" }
{ "port" "port number" }
{ "mdb" "mdb-db instance" }
}
{ $description "Create a new mdb-db instance and automatically resolves master/slave information in a paired MongoDB setup." }
{ $examples
{ $unchecked-example "USING: mongodb.driver ;" "\"db\" \"127.0.0.1\" 27017 <mdb>" "" } } ;
HELP: <query>
{ $values
{ "collection" "collection to query" }
{ "assoc" "query assoc" }
{ "mdb-query-msg" "mdb-query-msg instance" }
}
{ $description "Creates a new mdb-query-msg instance. "
"This word must be called from within a with-db scope."
"For more see: "
{ $link with-db } }
{ $examples
{ $unchecked-example "USING: mongodb.driver ;" "\"mycollection\" H{ } <query>" "" } } ;
HELP: <update>
{ $values
{ "collection" "collection to update" }
{ "selector" "selector assoc (selects which object(s) to update" }
{ "object" "updated object or update instruction" }
{ "mdb-update-msg" "mdb-update-msg instance" }
}
{ $description "Creates an update message for the object(s) identified by the given selector."
"MongoDB supports full object updates as well as partial update modifiers such as $set, $inc or $push"
"For more information see: " { $url "http://www.mongodb.org/display/DOCS/Updates" } } ;
HELP: >upsert
{ $values
{ "mdb-update-msg" "a mdb-update-msg" }
{ "mdb-update-msg" "mdb-update-msg with the upsert indicator set to t" }
}
{ $description "Marks a mdb-update-msg as upsert operation"
"(inserts object identified by the update selector if it doesn't exist in the collection)" } ;
HELP: PARTIAL?
{ $values
{ "value" "partial?" }
}
{ $description "key which refers to a partially loaded object" } ;
HELP: asc
{ $values
{ "key" "sort key" }
{ "spec" "sort spec" }
}
{ $description "indicates that the values of the specified key should be sorted in ascending order" } ;
HELP: count
{ $values
{ "mdb-query-msg" "query" }
{ "result" "number of objects in the collection that match the query" }
}
{ $description "count objects in a collection" } ;
HELP: create-collection
{ $values
{ "name" "collection name" }
}
{ $description "Creates a new collection with the given name." } ;
HELP: delete
{ $values
{ "collection" "a collection" }
{ "selector" "assoc which identifies the objects to be removed from the collection" }
}
{ $description "removes objects from the collection (with lasterror check)" } ;
HELP: delete-unsafe
{ $values
{ "collection" "a collection" }
{ "selector" "assoc which identifies the objects to be removed from the collection" }
}
{ $description "removes objects from the collection (without error check)" } ;
HELP: desc
{ $values
{ "key" "sort key" }
{ "spec" "sort spec" }
}
{ $description "indicates that the values of the specified key should be sorted in descending order" } ;
HELP: drop-collection
{ $values
{ "name" "a collection" }
}
{ $description "removes the collection and all objects in it from the database" } ;
HELP: drop-index
{ $values
{ "collection" "a collection" }
{ "name" "an index name" }
}
{ $description "drops the specified index from the collection" } ;
HELP: ensure-collection
{ $values
{ "name" "a collection; e.g. mycollection " }
}
{ $description "ensures that the collection exists in the database" } ;
HELP: ensure-index
{ $values
{ "index-spec" "an index specification" }
}
{ $description "Ensures the existence of the given index. "
"For more information on MongoDB indexes see: " { $url "http://www.mongodb.org/display/DOCS/Indexes" } }
{ $examples
{ $unchecked-example "USING: mongodb.driver ;"
"\"db\" \"127.0.0.1\" 27017 <mdb>"
"[ \"mycollection\" nameIdx [ \"name\" asc ] keyspec <index-spec> ensure-index ] with-db" "" }
{ $unchecked-example "USING: mongodb.driver ;"
"\"db\" \"127.0.0.1\" 27017 <mdb>" "[ \"mycollection\" nameIdx [ \"name\" asc ] keyspec <index-spec> unique-index ensure-index ] with-db" "" } } ;
HELP: explain.
{ $values
{ "mdb-query-msg" "a query message" }
}
{ $description "Prints the execution plan for the given query" } ;
HELP: find
{ $values
{ "selector" "a mdb-query or mdb-cursor" }
{ "mdb-cursor/f" "a cursor (if there are more results) or f" }
{ "seq" "a sequences of objects" }
}
{ $description "executes the given query" }
{ $examples
{ $unchecked-example "USING: mongodb.driver ;"
"\"db\" \"127.0.0.1\" 27017 <mdb>"
"[ \"mycollection\" H{ { \"name\" \"Alfred\" } } <query> find ] with-db" "" } } ;
HELP: find-one
{ $values
{ "mdb-query-msg" "a query" }
{ "result/f" "a single object or f" }
}
{ $description "Executes the query and returns one object at most" } ;
HELP: hint
{ $values
{ "mdb-query-msg" "a query" }
{ "index-hint" "a hint to an index" }
{ "mdb-query-msg" "modified query object" }
}
{ $description "Annotates the query with a hint to an index. "
"For detailed information see: " { $url "http://www.mongodb.org/display/DOCS/Optimizing+Mongo+Performance#OptimizingMongoPerformance-Hint" } }
{ $examples
{ $unchecked-example "USING: mongodb.driver ;"
"\"db\" \"127.0.0.1\" 27017 <mdb>"
"[ \"mycollection\" H{ { \"name\" \"Alfred\" } { \"age\" 70 } } <query> H{ { \"name\" 1 } } hint find ] with-db" "" } } ;
HELP: lasterror
{ $values
{ "error" "error message or f" }
}
{ $description "Checks if the last operation resulted in an error on the MongoDB side"
"For more information see: " { $url "http://www.mongodb.org/display/DOCS/Mongo+Commands#MongoCommands-LastErrorCommands" } } ;
HELP: limit
{ $values
{ "mdb-query-msg" "a query" }
{ "limit#" "number of objects that should be returned at most" }
{ "mdb-query-msg" "modified query object" }
}
{ $description "Limits the number of returned objects to limit#" }
{ $examples
{ $unchecked-example "USING: mongodb.driver ;"
"\"db\" \"127.0.0.1\" 27017 <mdb>"
"[ \"mycollection\" H{ } <query> 10 limit find ] with-db" "" } } ;
HELP: load-collection-list
{ $values
{ "collection-list" "list of collections in the current database" }
}
{ $description "Returns a list of all collections that exist in the current database" } ;
HELP: load-index-list
{ $values
{ "index-list" "list of indexes" }
}
{ $description "Returns a list of all indexes that exist in the current database" } ;
HELP: mdb-collection
{ $var-description "MongoDB collection" } ;
HELP: mdb-cursor
{ $var-description "MongoDB cursor" } ;
HELP: mdb-error
{ $values
{ "msg" "error message" }
}
{ $description "error class" } ;
HELP: r/
{ $values
{ "token" "a regexp string" }
{ "mdbregexp" "a mdbregexp tuple instance" }
}
{ $description "creates a new mdbregexp instance" } ;
HELP: save
{ $values
{ "collection" "a collection" }
{ "assoc" "object" }
}
{ $description "Saves the object to the given collection."
" If the object contains a field name \"_id\" this command automatically performs an update (with upsert) instead of a plain save" } ;
HELP: save-unsafe
{ $values
{ "collection" "a collection" }
{ "assoc" "object" }
}
{ $description "Save the object to the given collection without automatic error check" } ;
HELP: skip
{ $values
{ "mdb-query-msg" "a query message" }
{ "skip#" "number of objects to skip" }
{ "mdb-query-msg" "annotated query message" }
}
{ $description "annotates a query message with a number of objects to skip when returning the results" } ;
HELP: sort
{ $values
{ "mdb-query-msg" "a query message" }
{ "sort-quot" "a quotation with sort specifiers" }
{ "mdb-query-msg" "annotated query message" }
}
{ $description "annotates the query message for sort specifiers" } ;
HELP: update
{ $values
{ "mdb-update-msg" "a mdb-update message" }
}
{ $description "performs an update" } ;
HELP: update-unsafe
{ $values
{ "mdb-update-msg" "a mdb-update message" }
}
{ $description "performs an update without automatic error check" } ;
HELP: validate.
{ $values
{ "collection" "collection to validate" }
}
{ $description "validates the collection" } ;
HELP: with-db
{ $values
{ "mdb" "mdb instance" }
{ "quot" "quotation to execute with the given mdb instance as context" }
}
{ $description "executes a quotation with the given mdb instance in its context" } ;