1 ! Copyright (C) 2009 Sascha Matzke.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs help.markup help.syntax kernel quotations ;
8 { "name" "name of the collection" }
9 { "collection" "mdb-collection instance" }
11 { $examples { $unchecked-example "USING: mongodb.driver ;" "\"mycollection\" <mdb-collection> t >>capped 1000000 >>max" "" } }
12 { $description "Creates a new mdb-collection instance. Use this to create capped/limited collections." } ;
16 { "db" "name of the database to use" }
17 { "host" "host name or IP address" }
18 { "port" "port number" }
19 { "mdb" "mdb-db instance" }
21 { $description "Create a new mdb-db instance and automatically resolves master/slave information in a paired MongoDB setup." }
23 { $unchecked-example "USING: mongodb.driver ;" "\"db\" \"127.0.0.1\" 27017 <mdb>" "" } } ;
27 { "collection" "collection to query" }
28 { "assoc" "query assoc" }
29 { "mdb-query-msg" "mdb-query-msg instance" }
31 { $description "Creates a new mdb-query-msg instance. "
32 "This word must be called from within a with-db scope."
36 { $unchecked-example "USING: mongodb.driver ;" "\"mycollection\" H{ } <query>" "" } } ;
40 { "collection" "collection to update" }
41 { "selector" "selector assoc (selects which object(s) to update" }
42 { "object" "updated object or update instruction" }
43 { "mdb-update-msg" "mdb-update-msg instance" }
45 { $description "Creates an update message for the object(s) identified by the given selector."
46 "MongoDB supports full object updates as well as partial update modifiers such as $set, $inc or $push"
47 "For more information see: " { $url "http://www.mongodb.org/display/DOCS/Updates" } } ;
51 { "mdb-update-msg" "a mdb-update-msg" }
53 { $description "Marks a mdb-update-msg as upsert operation"
54 "(inserts object identified by the update selector if it doesn't exist in the collection)" } ;
58 { "value" "partial?" }
60 { $description "key which refers to a partially loaded object" } ;
65 { "spec" "sort spec" }
67 { $description "indicates that the values of the specified key should be sorted in ascending order" } ;
71 { "mdb-query-msg" "query" }
72 { "result" "number of objects in the collection that match the query" }
74 { $description "count objects in a collection" } ;
76 HELP: create-collection
78 { "name/collection" "collection name" }
80 { $description "Creates a new collection with the given name." } ;
84 { "mdb-delete-msg" "a delete msg" }
86 { $description "removes objects from the collection (with lasterror check)" } ;
90 { "mdb-delete-msg" "a delete msg" }
92 { $description "removes objects from the collection (without error check)" } ;
97 { "spec" "sort spec" }
99 { $description "indicates that the values of the specified key should be sorted in descending order" } ;
101 HELP: drop-collection
103 { "name" "a collection" }
105 { $description "removes the collection and all objects in it from the database" } ;
109 { "collection" "a collection" }
110 { "name" "an index name" }
112 { $description "drops the specified index from the collection" } ;
114 HELP: ensure-collection
116 { "name" "a collection; e.g. mycollection " }
118 { $description "ensures that the collection exists in the database" } ;
122 { "index-spec" "an index specification" }
124 { $description "Ensures the existence of the given index. "
125 "For more information on MongoDB indexes see: " { $url "http://www.mongodb.org/display/DOCS/Indexes" } }
127 { $unchecked-example "USING: mongodb.driver ;"
128 "\"db\" \"127.0.0.1\" 27017 <mdb>"
129 "[ \"mycollection\" nameIdx [ \"name\" asc ] keyspec <index-spec> ensure-index ] with-db" "" }
130 { $unchecked-example "USING: mongodb.driver ;"
131 "\"db\" \"127.0.0.1\" 27017 <mdb>" "[ \"mycollection\" nameIdx [ \"name\" asc ] keyspec <index-spec> t >>unique? ensure-index ] with-db" "" } } ;
135 { "mdb-query-msg" "a query message" }
137 { $description "Prints the execution plan for the given query" } ;
141 { "selector" "a mdb-query or mdb-cursor" }
142 { "mdb-cursor/f" "a cursor (if there are more results) or f" }
143 { "seq" "a sequences of objects" }
145 { $description "executes the given query" }
147 { $unchecked-example "USING: mongodb.driver ;"
148 "\"db\" \"127.0.0.1\" 27017 <mdb>"
149 "[ \"mycollection\" H{ { \"name\" \"Alfred\" } } <query> find ] with-db" "" } } ;
153 { "mdb-query-msg" "a query" }
154 { "result/f" "a single object or f" }
156 { $description "Executes the query and returns one object at most" } ;
160 { "mdb-query-msg" "a query" }
161 { "index-hint" "a hint to an index" }
163 { $description "Annotates the query with a hint to an index. "
164 "For detailed information see: " { $url "http://www.mongodb.org/display/DOCS/Optimizing+Mongo+Performance#OptimizingMongoPerformance-Hint" } }
166 { $unchecked-example "USING: mongodb.driver ;"
167 "\"db\" \"127.0.0.1\" 27017 <mdb>"
168 "[ \"mycollection\" H{ { \"name\" \"Alfred\" } { \"age\" 70 } } <query> H{ { \"name\" 1 } } hint find ] with-db" "" } } ;
173 { "error" "error message or f" }
175 { $description "Checks if the last operation resulted in an error on the MongoDB side"
176 "For more information see: " { $url "http://www.mongodb.org/display/DOCS/Mongo+Commands#MongoCommands-LastErrorCommands" } } ;
180 { "mdb-query-msg" "a query" }
181 { "limit#" "number of objects that should be returned at most" }
183 { $description "Limits the number of returned objects to limit#" }
185 { $unchecked-example "USING: mongodb.driver ;"
186 "\"db\" \"127.0.0.1\" 27017 <mdb>"
187 "[ \"mycollection\" H{ } <query> 10 limit find ] with-db" "" } } ;
189 HELP: load-collection-list
192 { "collection-list" "list of collections in the current database" }
194 { $description "Returns a list of all collections that exist in the current database" } ;
196 HELP: load-index-list
199 { "index-list" "list of indexes" }
201 { $description "Returns a list of all indexes that exist in the current database" } ;
204 { $var-description "MongoDB collection" } ;
207 { $var-description "MongoDB cursor" } ;
211 { "msg" "error message" }
213 { $description "error class" } ;
217 { "token" "a regexp string" }
218 { "mdbregexp" "a mdbregexp tuple instance" }
220 { $description "creates a new mdbregexp instance" } ;
224 { "collection" "a collection" }
227 { $description "Saves the object to the given collection."
228 " If the object contains a field name \"_id\" this command automatically performs an update (with upsert) instead of a plain save" } ;
232 { "collection" "a collection" }
235 { $description "Save the object to the given collection without automatic error check" } ;
239 { "mdb-query-msg" "a query message" }
240 { "skip#" "number of objects to skip" }
242 { $description "annotates a query message with a number of objects to skip when returning the results" } ;
246 { "mdb-query-msg" "a query message" }
247 { "sort-quot" "a quotation with sort specifiers" }
249 { $description "annotates the query message for sort specifiers" } ;
253 { "mdb-update-msg" "a mdb-update message" }
255 { $description "performs an update" } ;
259 { "mdb-update-msg" "a mdb-update message" }
261 { $description "performs an update without automatic error check" } ;
265 { "collection" "collection to validate" }
267 { $description "validates the collection" } ;
271 { "mdb" "mdb instance" }
272 { "quot" "quotation to execute with the given mdb instance as context" }
274 { $description "executes a quotation with the given mdb instance in its context" } ;