diff --git a/Documentation/Books/Users/Databases/WorkingWith.mdpp b/Documentation/Books/Users/Databases/WorkingWith.mdpp index 07f65abf06..ac20d18952 100644 --- a/Documentation/Books/Users/Databases/WorkingWith.mdpp +++ b/Documentation/Books/Users/Databases/WorkingWith.mdpp @@ -6,6 +6,7 @@ The following methods are available to manage databases via JavaScript. Please note that several of these methods can be used from the _system database only. + @startDocuBlock databaseName diff --git a/Documentation/Books/Users/Documents/DatabaseMethods.mdpp b/Documentation/Books/Users/Documents/DatabaseMethods.mdpp index 9ecc64c353..69db12de56 100644 --- a/Documentation/Books/Users/Documents/DatabaseMethods.mdpp +++ b/Documentation/Books/Users/Documents/DatabaseMethods.mdpp @@ -1,163 +1,21 @@ !CHAPTER Database Methods -`db._document( document)` +!SUBSECTION Document + +@startDocuBlock documentsDocumentName -This method finds a document given its identifier. It returns the document. Note that the returned document contains some pseudo-attributes, namely _id, _key, and _rev. _id and _key contain the document handle and key, and _rev contains the revision of the document. +!SUBSECTION Exists + +@startDocuBlock documentsDocumentExists -An error is thrown if the _rev does not longer match the current revision of the document. +!SUBSECTION Replace + +@startDocuBlock documentsDocumentReplace -`db._document( document-handle)` +!SUBSECTION Update + +@startDocuBlock documentsDocumentUpdate -As before. Instead of document a document-handle can be passed as first argument. - -*Examples* - -Returns the document: - - arango> db._document("example/3053939"); - { "_id" : "example/3053939", "_key" : "3053939", "_rev" : "3053939", "Hello" : "World" } - -`db._exists( document)` - -This method determines whether a document exists given its identifier. Instead of returning the found document or an error, this method will return either true or false. It can thus be used for easy existence checks. - -No error will be thrown if the sought document or collection does not exist. Still this method will throw an error if used improperly, e.g. when called with a non-document handle. - -`db._exists( document-handle)` - -`db._replace( document, data)` - -The method returns a document with the attributes _id, _rev and _oldRev. The attribute _id contains the document handle of the updated document, the attribute _rev contains the document revision of the updated document, the attribute _oldRev contains the revision of the old (now replaced) document. - -If there is a conflict, i. e. if the revision of the document does not match the revision in the collection, then an error is thrown. - -`db._replace( document, data, true)` - -As before, but in case of a conflict, the conflict is ignored and the old document is overwritten. - -`db._replace( document, data, true, waitForSync)` - -The optional waitForSync parameter can be used to force synchronisation of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection. Thus, the waitForSync parameter can be used to force synchronisation of just specific operations. To use this, set the waitForSync parameter to true. If the waitForSync parameter is not specified or set to false, then the collection's default waitForSync behavior is applied. The waitForSync parameter cannot be used to disable synchronisation for collections that have a default waitForSync value of true. - -`db._replace( document-handle, data)` - -As before. Instead of document a document-handle can be passed as first argument. - -*Examples* - -Create and replace a document: - - arango> a1 = db.example.save({ a : 1 }); - { "_id" : "example/1717678", "_key" : "1717678", "_rev" : "1717678" } - arango> a2 = db._replace(a1, { a : 2 }); - { "_id" : "example/1717678", "_key" : "1717678", "_rev" : "1783214", "_oldRev" : "1717678" } - arango> a3 = db._replace(a1, { a : 3 }); - JavaScript exception in file '(arango)' at 1,9: [ArangoError 1200: conflict: cannot replace document] - !a3 = db._replace(a1, { a : 3 }); - ! ^ - arango> a4 = db.example.replace(a1, { a : 4 }, true); - { "_id" : "example/1717678", "_key" : "1717678", "_rev" : "1848750", "_oldRev" : "1783214" } - -`db._update( document, data, overwrite, keepNull, waitForSync)` - -Updates an existing document. The document must be a document in the current collection. This document is then patched with the data given as second argument. The optional overwrite parameter can be used to control the behavior in case of version conflicts (see below). The optional keepNull parameter can be used to modify the behavior when handling null values. Normally, null values are stored in the database. By setting the keepNull parameter to false, this behavior can be changed so that all attributes in data with null values will be removed from the target document. - -The optional waitForSync parameter can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection. Thus, the waitForSync parameter can be used to force synchronisation of just specific operations. To use this, set the waitForSync parameter to true. If the waitForSync parameter is not specified or set to false, then the collection's default waitForSync behavior is applied. The waitForSync parameter cannot be used to disable synchronisation for collections that have a default waitForSync value of true. - -The method returns a document with the attributes _id, _rev and _oldRev. The attribute _id contains the document handle of the updated document, the attribute _rev contains the document revision of the updated document, the attribute _oldRev contains the revision of the old (now replaced) document. - -If there is a conflict, i. e. if the revision of the document does not match the revision in the collection, then an error is thrown. - -`db._update( document, data, true)` - -As before, but in case of a conflict, the conflict is ignored and the old document is overwritten. - -`db._update( document-handle, data)` - -As before. Instead of document a document-handle can be passed as first argument. - -*Examples* - -Create and update a document: - - arango> a1 = db.example.save({ a : 1 }); - { "error" : false, "_id" : "example/19660691", "_key" : "19660691", "_rev" : "19660691" } - arango> a2 = db._update(a1, { b : 2 }); - { "error" : false, "_id" : "example/19660691", "_key" : "19660691", "_rev" : "19791763" } - arango> a3 = db._update(a1, { c : 3 }); - JavaScript exception in file 'client/client.js' at 2364,13: [ArangoError 1200: precondition failed] - ! throw new ArangoError(requestResult); - ! ^ - arango> a4 = db.example.update(a1, { c : 3 }, true); - { "error" : false, "_id" : "example/19660691", "_key" : "19660691", "_rev" : "19857299" } - -`db._remove( document)` - -Removes a document. If there is revision mismatch, then an error is thrown. - -`db._remove( document, true)` - -Removes a document. If there is revision mismatch, then mismatch is ignored and document is deleted. The function returns true if the document existed and was deleted. It returns false, if the document was already deleted. - -`db._remove( document, true, waitForSync)` - -The optional waitForSync parameter can be used to force synchronisation of the document deletion operation to disk even in case that the waitForSync flag had been disabled for the entire collection. Thus, the waitForSync parameter can be used to force synchronisation of just specific operations. To use this, set the waitForSync parameter to true. If the waitForSync parameter is not specified or set to false, then the collection's default waitForSync behavior is applied. The waitForSync parameter cannot be used to disable synchronisation for collections that have a default waitForSync value of true. - -`db._remove( document-handle, data)` - -As before. Instead of document a document-handle can be passed as first argument. - -*Examples* - -Remove a document: - - arango> a1 = db.example.save({ a : 1 }); - { "_id" : "116308/4214943", "_rev" : "4214943" } - arango> db._remove(a1); - true - arango> db._remove(a1); - JavaScript exception in file '(arango)' at 1,4: [ArangoError 1202: document not found: cannot remove document] - !db._remove(a1); - ! ^ - arango> db._remove(a1, true); - false - -Remove a document with a conflict: - - arango> a1 = db.example.save({ a : 1 }); - { "_id" : "116308/4042634", "_rev" : "4042634" } - arango> a2 = db._replace(a1, { a : 2 }); - { "_id" : "116308/4042634", "_rev" : "4108170", "_oldRev" : 4042634 } - arango> db._delete(a1); - JavaScript exception in file '(arango)' at 1,4: [ArangoError 1200: conflict: cannot delete document] - !db._delete(a1); - ! ^ - arango> db._delete(a1, true); - true - arango> db._document(a1); - JavaScript exception in file '(arango)' at 1,4: [ArangoError 1202: document not found: document not found] - !db._document(a1); - ! ^ - - \ No newline at end of file +!SUBSECTION Remove + +@startDocuBlock documentsDocumentRemove diff --git a/Documentation/Books/Users/Documents/DocumentAddress.mdpp b/Documentation/Books/Users/Documents/DocumentAddress.mdpp index 51acae6695..ccdd25c4c0 100644 --- a/Documentation/Books/Users/Documents/DocumentAddress.mdpp +++ b/Documentation/Books/Users/Documents/DocumentAddress.mdpp @@ -6,7 +6,7 @@ documents of a collection as: db.collection.document("document-handle") -For example: Assume that the document handle, which is stored in the `_id` field +For example: Assume that the document handle, which is stored in the *_id* field of the document, is *demo/362549* and the document lives in a collection named *demo*, then that document can be accessed as: diff --git a/Documentation/Books/Users/Documents/DocumentMethods.mdpp b/Documentation/Books/Users/Documents/DocumentMethods.mdpp index e54f08dffe..aee69a7cfd 100644 --- a/Documentation/Books/Users/Documents/DocumentMethods.mdpp +++ b/Documentation/Books/Users/Documents/DocumentMethods.mdpp @@ -1,185 +1,42 @@ !CHAPTER Collection Methods -`collection.all()` +!SUBSECTION All + +@startDocuBlock collectionAll -Selects all documents of a collection and returns a cursor. You can use toArray, next, or hasNext to access the result. The result can be limited using the skip and limit operator. +!SUBSECTION Query by example + +@startDocuBlock collectionByExample -*Examples* +!SUBSECTION First Example + +@startDocuBlock collectionFirstExample -Use toArray to get all documents at once: +!SUBSECTION Range + +@startDocuBlock collectionRange - arango> db.five.all().toArray(); - [ - { "_id" : "five/1798296", "_key" : "1798296", "_rev" : "1798296", "doc" : 3 }, - { "_id" : "five/1732760", "_key" : "1732760", "_rev" : "1732760", "doc" : 2 }, - { "_id" : "five/1863832", "_key" : "1863832", "_rev" : "1863832", "doc" : 4 }, - { "_id" : "five/1667224", "_key" : "1667224", "_rev" : "1667224", "doc" : 1 }, - { "_id" : "five/1929368", "_key" : "1929368", "_rev" : "1929368", "doc" : 5 } - ] +!SUBSECTION Any + +@startDocuBlock documentsCollectionAny -Use next to loop over all documents: +!SUBSECTION Count + +@startDocuBlock colllectionCount - arango> var a = db.five.all(); - arango> while (a.hasNext()) print(a.next()); - { "_id" : "five/1798296", "_key" : "1798296", "_rev" : "1798296", "doc" : 3 } - { "_id" : "five/1732760", "_key" : "1732760", "_rev" : "1732760", "doc" : 2 } - { "_id" : "five/1863832", "_key" : "1863832", "_rev" : "1863832", "doc" : 4 } - { "_id" : "five/1667224", "_key" : "1667224", "_rev" : "1667224", "doc" : 1 } - { "_id" : "five/1929368", "_key" : "1929368", "_rev" : "1929368", "doc" : 5 } +!SUBSECTION toArray + +@startDocuBlock collectionToArray -`collection.byExample( example)` +!SUBSECTION First + +@startDocuBlock documentsCollectionFirst -Selects all documents of a collection that match the specified example and returns a cursor. +!SUBSECTION Last + +@startDocuBlock documentsCollectionLast -You can use toArray, next, or hasNext to access the result. The result can be limited using the skip and limit operator. -An attribute name of the form a.b is interpreted as attribute path, not as attribute. If you use - - { a : { c : 1 } } - -as example, then you will find all documents, such that the attribute a contains a document of the form {c : 1 }. E.g., the document - - { a : { c : 1 }, b : 1 } - -will match, but the document - - { a : { c : 1, b : 1 } } - -will not. - -However, if you use - - { a.c : 1 }, - -then you will find all documents, which contain a sub-document in a that has an attribute c of value 1. E.g., both documents - - { a : { c : 1 }, b : 1 } and - { a : { c : 1, b : 1 } } - -will match. - -`collection.byExample( path1, value1, ...)` - -As alternative you can supply a list of paths and values. - -*Examples* - -Use toArray to get all documents at once: - - arango> db.users.all().toArray(); - [ { "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285", "id" : 323, "name" : "Peter" }, - { "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749", "id" : 535, "name" : "Peter" }, - { "_id" : "users/554833357", "_key" : "554833357", "_rev" : "554833357", "id" : 25, "name" : "Vladimir" } ] - - arango> db.users.byExample({ "id" : 323 }).toArray(); - [ { "id" : 323, "name" : "Peter", "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285" } ] - - arango> db.users.byExample({ "name" : "Peter" }).toArray(); - [ { "id" : 323, "name" : "Peter", "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285" }, - { "id" : 535, "name" : "Peter", "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749" } ] - - arango> db.users.byExample({ "name" : "Peter", "id" : 535 }).toArray(); - [ { "id" : 535, "name" : "Peter", "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749" } ] - -Use next to loop over all documents: - - arango> var a = db.users.byExample( {"name" : "Peter" } ); - arango> while (a.hasNext()) print(a.next()); - { "id" : 323, "name" : "Peter", "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285" } - { "id" : 535, "name" : "Peter", "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749" } - -`collection.firstExample( example)` - -Returns the document of a collection that match the specified example or null. The example must be specified as paths and values. See byExample for details. - -`collection.firstExample( path1, value1, ...)` - -As alternative you can supply a list of paths and values. - -*Examples* - - arango> db.users.firstExample("name", 1237); - { "_id" : "users/83049373", "_key" : "83049373", "_rev" : "83049373", "name" : 1237 } - -`collection.range( attribute, left, right)` - -Selects all documents of a collection such that the attribute is greater or equal than left and strictly less than right. - -You can use toArray, next, or hasNext to access the result. The result can be limited using the skip and limit operator. - -An attribute name of the form a.b is interpreted as attribute path, not as attribute. - -For range queries it is required that a skiplist index is present for the queried attribute. If no skiplist index is present on the attribute, an error will be thrown. - -*Examples* - -Use toArray to get all documents at once: - - arangod> l = db.skip.range("age", 10, 13).toArray(); - [ - { "_id" : "skip/4260278", "_key" : "4260278", "_rev" : "4260278", "age" : 10 }, - { "_id" : "skip/4325814", "_key" : "4325814", "_rev" : "4325814", "age" : 11 }, - { "_id" : "skip/4391350", "_key" : "4391350", "_rev" : "4391350", "age" : 12 } - ] - -`collection.any()` - -The any method returns a random document from the collection. It returns null if the collection is empty. - -*Examples* - - arangod> db.example.any() - { "_id" : "example/222716379559", "_rev" : "222716379559", "Hello" : "World" } - -`collection.count()` - -Returns the number of living documents in the collection. - -*Examples* - - arango> db.users.count(); - 10001 - -`collection.toArray()` - -Converts the collection into an array of documents. Never use this call in a production environment. - - `collection.document( document)` diff --git a/Documentation/Books/Users/Documents/README.mdpp b/Documentation/Books/Users/Documents/README.mdpp index d51c05dcda..2c1d079c01 100644 --- a/Documentation/Books/Users/Documents/README.mdpp +++ b/Documentation/Books/Users/Documents/README.mdpp @@ -10,29 +10,24 @@ and may contain lists. Each document is uniquely identified by its document hand For example: - { - "firstName" : "Hugo", - "lastName" : "Schlonz", - "address" : { - "city" : "Hier", - "street" : "Strasse 1" - }, - "hobbies" : [ - "swimming", - "biking", - "programming" - ], - "_id" : "demo/schlonz", - "_rev" : "13728680", - "_key" : "schlonz" - } - - - +```js +{ + "firstName" : "Hugo", + "lastName" : "Schlonz", + "address" : { + "city" : "Hier", + "street" : "Strasse 1" + }, + "hobbies" : [ + "swimming", + "biking", + "programming" + ], + "_id" : "demo/schlonz", + "_rev" : "13728680", + "_key" : "schlonz" +} +``` All documents contain special attributes: the document handle in *_id*, the document's unique key in *_key* and and the ETag aka document revision in *_rev*. The value of the *_key* attribute can be specified by the user when @@ -61,7 +56,7 @@ changed or not), but they should not use revision ids to perform greater/less th comparisons with them to check if a document revision is older than one another, even if this might work for some cases. -Note: Revision ids have been returned as integers up to including ArangoDB 1.1 +**Note**: Revision ids have been returned as integers up to including ArangoDB 1.1 -Document Etag: The document revision enclosed in double quotes. The revision is +*Document Etag*: The document revision enclosed in double quotes. The revision is returned by several HTTP API methods in the Etag HTTP header. diff --git a/Documentation/Books/Users/HttpGharial/Management.mdpp b/Documentation/Books/Users/HttpGharial/Management.mdpp index 069260f47a..9becf19241 100644 --- a/Documentation/Books/Users/HttpGharial/Management.mdpp +++ b/Documentation/Books/Users/HttpGharial/Management.mdpp @@ -15,7 +15,7 @@ definition, at least one is needed. @RESTHEADER{GET /_api/gharial, List all graphs} @RESTDESCRIPTION -Lists all graph names stored in this database. +Lists all graph names stored in this database.ssss @RESTRETURNCODES diff --git a/Documentation/Books/bot.py b/Documentation/Books/bot.py index 6a4a1e1789..9af4c7cf27 100644 --- a/Documentation/Books/bot.py +++ b/Documentation/Books/bot.py @@ -27,12 +27,6 @@ def getTextFromSourceFile(searchText, full_path): if match: textExtracted = match.group(1) textExtracted = textExtracted.replace("
","\n") - textExtracted = re.sub(r"@RESTHEADER{(.*)}", r"*\g<1>*", textExtracted) - textExtracted = re.sub(r"@RESTRETURNCODE{(.*)}", r"*HTTP \g<1>*", textExtracted) - textExtracted = re.sub(r"@RESTBODYPARAM{(.*)}", r"*(\g<1>)*", textExtracted) - textExtracted = textExtracted.replace("@RESTDESCRIPTION","") - textExtracted = textExtracted.replace("@EXAMPLES","*Examples*") - textExtracted = textExtracted.replace("@RESTRETURNCODES","###Return Codes") replaceText(textExtracted, full_path, searchText) def replaceText(text, pathOfFile, searchText): @@ -42,11 +36,28 @@ def replaceText(text, pathOfFile, searchText): f.close() f=open(pathOfFile,'w') - replaced=re.sub("@startDocuBlock\s+"+ searchText + "(?:\s+|$)",text,s) + replaced = re.sub("@startDocuBlock\s+"+ searchText + "(?:\s+|$)",text,s) + + # HTTP API changing code + replaced = replaced.replace("@brief","") + replaced = re.sub(r"@RESTHEADER{(.*)}", r"`\g<1>`", replaced) + replaced = replaced.replace("@RESTDESCRIPTION","") + replaced = replaced.replace("@RESTURLPARAMS","*URL Parameters*") + replaced = replaced.replace("@RESTQUERYPARAMS","*Query Parameters*") + replaced = replaced.replace("@RESTHEADERPARAMS","*Header Parameters*") + replaced = replaced.replace("@RESTBODYPARAMS","*Body Parameters*") + replaced = replaced.replace("@RESTRETURNCODES","*Return Codes*") + replaced = re.sub(r"@RESTPARAM{(\s*\w+\-*\w+),(\s*\w+),\s*(\w+)}", r"* *\g<1>* (\g<3>):", replaced) + # replaced = re.sub(r"@RESTPARAM{(\s*\w+\-*\w+),(\s*\w+),\s*(\w+)}", r"* *\g<1>* (\g<3>):", replaced) + replaced = re.sub(r"@RESTRETURNCODE{(.*)}", r"* *HTTP \g<1>*:", replaced) + replaced = re.sub(r"@RESTBODYPARAMS{(.*)}", r"*(\g<1>)*", replaced) + replaced = replaced.replace("__EXAMPLES__","*Examples*") + replaced = replaced.replace("@EXAMPLES","*Examples*") f.write(replaced) f.close() + if __name__ == '__main__': path = ["Documentation/Books/Users"] for i in path: diff --git a/Documentation/Examples/shell-collection-count b/Documentation/Examples/shell-collection-count deleted file mode 100644 index 07bccf566b..0000000000 --- a/Documentation/Examples/shell-collection-count +++ /dev/null @@ -1,2 +0,0 @@ -arango> db.users.count(); -10001 diff --git a/Documentation/Examples/shell-simple-query-first-example b/Documentation/Examples/shell-simple-query-first-example deleted file mode 100644 index b7bdd88cb1..0000000000 --- a/Documentation/Examples/shell-simple-query-first-example +++ /dev/null @@ -1,2 +0,0 @@ -arango> db.users.firstExample("name", 1237); -{ "_id" : "users/83049373", "_key" : "83049373", "_rev" : "83049373", "name" : 1237 } diff --git a/Documentation/Examples/shell_collection-drop b/Documentation/Examples/shell_collection-drop deleted file mode 100644 index 24c149c7f6..0000000000 --- a/Documentation/Examples/shell_collection-drop +++ /dev/null @@ -1,5 +0,0 @@ -arango> col = db.examples; -[ArangoCollection 109757, "examples" (status unloaded)] -arango> col.drop() -arango> col; -[ArangoCollection 109757, "examples" (status deleted)] diff --git a/Documentation/Examples/shell_collection-drop-db b/Documentation/Examples/shell_collection-drop-db deleted file mode 100644 index e599acbb16..0000000000 --- a/Documentation/Examples/shell_collection-drop-db +++ /dev/null @@ -1,5 +0,0 @@ -arango> col = db.examples; -[ArangoCollection 109757, "examples" (status unloaded)] -arango> db._drop(col) -arango> col; -[ArangoCollection 109757, "examples" (status deleted)] diff --git a/Documentation/Examples/shell_collection-drop-name-db b/Documentation/Examples/shell_collection-drop-name-db deleted file mode 100644 index 658b684eec..0000000000 --- a/Documentation/Examples/shell_collection-drop-name-db +++ /dev/null @@ -1,5 +0,0 @@ -arango> col = db.examples; -[ArangoCollection 85198, "examples" (status new born)] -arango> db._drop("examples"); -arango> col; -[ArangoCollection 85198, "examples" (status deleted)] diff --git a/Documentation/Examples/shell_collection-figures b/Documentation/Examples/shell_collection-figures deleted file mode 100644 index 965ff99518..0000000000 --- a/Documentation/Examples/shell_collection-figures +++ /dev/null @@ -1,3 +0,0 @@ -arango> db.demo.figures() -{ "alive" : { "count" : 1000, "size" : 45000 }, "dead" : { "count" : 0, "size" : 0, "deletion" : 0 }, "datafiles" : { "count" : 0, "fileSize" : 0 }, "journals" : { "count" : 1, "fileSize" : 33554432 }, "shapes" : { "count" : 7 } } - diff --git a/Documentation/Examples/shell_collection-properties b/Documentation/Examples/shell_collection-properties deleted file mode 100644 index 479c8e8d5c..0000000000 --- a/Documentation/Examples/shell_collection-properties +++ /dev/null @@ -1,2 +0,0 @@ -arango> db.examples.properties() -{ "waitForSync" : false, "journalSize" : 33554432, "isVolatile" : false } diff --git a/Documentation/Examples/shell_collection-properties-change b/Documentation/Examples/shell_collection-properties-change deleted file mode 100644 index 40e64b14d9..0000000000 --- a/Documentation/Examples/shell_collection-properties-change +++ /dev/null @@ -1,2 +0,0 @@ -arango> db.examples.properties({ waitForSync : false }) -{ "waitForSync" : false, "journalSize" : 33554432, "isVolatile" : false } diff --git a/Documentation/Examples/shell_collection-rename b/Documentation/Examples/shell_collection-rename deleted file mode 100644 index 6d0147fcd3..0000000000 --- a/Documentation/Examples/shell_collection-rename +++ /dev/null @@ -1,5 +0,0 @@ -arango> c = db.example; -[ArangoCollection 68519, "example" (status new born)] -arango> c.rename("better-example"); -arango> c; -[ArangoCollection 68519, "better-example" (status new born)] diff --git a/Documentation/Examples/shell_collection-truncate-db b/Documentation/Examples/shell_collection-truncate-db deleted file mode 100644 index a63aa60c62..0000000000 --- a/Documentation/Examples/shell_collection-truncate-db +++ /dev/null @@ -1,9 +0,0 @@ -arango> col = db.examples; -[ArangoCollection 91022, "examples" (status unloaded)] -arango> col.save({ "Hello" : "World" }); -{ "_id" : "examples/1532814", "_key" : "1532814", "_rev" : "1532814" } -arango> col.count(); -1 -arango> db._truncate(col); -arango> col.count(); -0 diff --git a/Documentation/Examples/shell_collection-truncate-name-db b/Documentation/Examples/shell_collection-truncate-name-db deleted file mode 100644 index 64043ae2f4..0000000000 --- a/Documentation/Examples/shell_collection-truncate-name-db +++ /dev/null @@ -1,9 +0,0 @@ -arango> col = db.examples; -[ArangoCollection 91022, "examples" (status unloaded)] -arango> col.save({ "Hello" : "World" }); -{ "_id" : "examples/1532814", "_key" : "1532814", "_rev" : "1532814" } -arango> col.count(); -1 -arango> db._truncate("examples"); -arango> col.count(); -0 diff --git a/Documentation/Examples/shell_collection-unload b/Documentation/Examples/shell_collection-unload deleted file mode 100644 index 6d3db6a575..0000000000 --- a/Documentation/Examples/shell_collection-unload +++ /dev/null @@ -1,5 +0,0 @@ -arango> col = db.example; -[ArangoCollection 164208316, "example" (status loaded)] -arango> col.unload(); -arango> col; -[ArangoCollection 164208316, "example" (status unloaded)] diff --git a/Documentation/Examples/shell_create-collection b/Documentation/Examples/shell_create-collection deleted file mode 100644 index 5a07e58167..0000000000 --- a/Documentation/Examples/shell_create-collection +++ /dev/null @@ -1,4 +0,0 @@ -arango> c = db._create("cars"); -[ArangoCollection 111137, "cars" (status loaded)] -arango> c.properties() -{ "waitForSync" : false, "journalSize" : 33554432, "isVolatile" : false } diff --git a/Documentation/Examples/shell_create-collection-keygen b/Documentation/Examples/shell_create-collection-keygen deleted file mode 100644 index 97b7ebb77d..0000000000 --- a/Documentation/Examples/shell_create-collection-keygen +++ /dev/null @@ -1,9 +0,0 @@ -arango> db._create("users", { keyOptions: { type: "autoincrement", offset: 10, increment: 5 } }); -[ArangoCollection 1533103587969, "users" (type document, status loaded)] - -arango> db.users.save({ name: "user 1" }); -{ "_id" : "users/10", "_rev" : "1533104964225", "_key" : "10" } -arango> db.users.save({ name: "user 2" }); -{ "_id" : "users/15", "_rev" : "1533105095297", "_key" : "15" } -arango> db.users.save({ name: "user 3" }); -{ "_id" : "users/20", "_rev" : "1533105226369", "_key" : "20" } diff --git a/Documentation/Examples/shell_create-collection-keyoptions b/Documentation/Examples/shell_create-collection-keyoptions deleted file mode 100644 index a4323954d7..0000000000 --- a/Documentation/Examples/shell_create-collection-keyoptions +++ /dev/null @@ -1,12 +0,0 @@ -arangod> db._create("users", { keyOptions: { allowUserKeys: false } }); -[ArangoCollection 1533105490832, "users" (type document, status loaded)] - -arangod> db.users.save({ name: "user 1" }); -{ "_id" : "users/1533106867088", "_rev" : "1533106867088", "_key" : "1533106867088" } - -arangod> db.users.save({ name: "user 2", _key: "myuser" }); -JavaScript exception in file '(arango)' at 1,10: [ArangoError 1222: cannot save document: unexpected document key] -!db.users.save({ name: "user 2", _key: "myuser" }); -! ^ -stacktrace: Error: cannot save document: unexpected document key - at (arango):1:10 diff --git a/Documentation/Examples/shell_create-collection-properties b/Documentation/Examples/shell_create-collection-properties deleted file mode 100644 index 7fce4074d0..0000000000 --- a/Documentation/Examples/shell_create-collection-properties +++ /dev/null @@ -1,4 +0,0 @@ -arango> c = db._create("cars", { waitForSync : true, journalSize : 1024 * 1204 }); -[ArangoCollection 96384, "cars" (status loaded)] -arango> c.properties() -{ "waitForSync" : true, "journalSize" : 1232896, "isVolatile" : false } diff --git a/Documentation/Examples/shell_read-collection-all b/Documentation/Examples/shell_read-collection-all deleted file mode 100644 index 92d8a0e2d8..0000000000 --- a/Documentation/Examples/shell_read-collection-all +++ /dev/null @@ -1,4 +0,0 @@ -arango> db.examples.load(); -arango> var d = db.demo; -arango> db._collections(); -[[ArangoCollection 96393, "examples" (status loaded)], [ArangoCollection 1407113, "demo" (status new born)]] diff --git a/Documentation/Examples/shell_read-collection-id b/Documentation/Examples/shell_read-collection-id deleted file mode 100644 index b1886004f0..0000000000 --- a/Documentation/Examples/shell_read-collection-id +++ /dev/null @@ -1,2 +0,0 @@ -arango> db._collection(145387); -[ArangoCollection 145387, "demo" (status loaded)] diff --git a/Documentation/Examples/shell_read-collection-name b/Documentation/Examples/shell_read-collection-name deleted file mode 100644 index ceca28722f..0000000000 --- a/Documentation/Examples/shell_read-collection-name +++ /dev/null @@ -1,2 +0,0 @@ -arango> db._collection("demo"); -[ArangoCollection 145387, "demo" (status loaded)] diff --git a/Documentation/Examples/shell_read-collection-short-cut b/Documentation/Examples/shell_read-collection-short-cut deleted file mode 100644 index d4c0a8bb9d..0000000000 --- a/Documentation/Examples/shell_read-collection-short-cut +++ /dev/null @@ -1,2 +0,0 @@ -arango> db.examples; -[ArangoCollection 110371, "examples" (status new born)] diff --git a/Documentation/Examples/shell_read-collection-unknown b/Documentation/Examples/shell_read-collection-unknown deleted file mode 100644 index 524dd94a3d..0000000000 --- a/Documentation/Examples/shell_read-collection-unknown +++ /dev/null @@ -1,2 +0,0 @@ -arango> db._collection("unknown") -null diff --git a/Documentation/Examples/simple-query-range-to-array b/Documentation/Examples/simple-query-range-to-array deleted file mode 100644 index 6f6d83e5f7..0000000000 --- a/Documentation/Examples/simple-query-range-to-array +++ /dev/null @@ -1,6 +0,0 @@ -arangod> l = db.skip.range("age", 10, 13).toArray(); -[ - { "_id" : "skip/4260278", "_key" : "4260278", "_rev" : "4260278", "age" : 10 }, - { "_id" : "skip/4325814", "_key" : "4325814", "_rev" : "4325814", "age" : 11 }, - { "_id" : "skip/4391350", "_key" : "4391350", "_rev" : "4391350", "age" : 12 } -] diff --git a/Documentation/Examples/simple18 b/Documentation/Examples/simple18 deleted file mode 100644 index 09648174ea..0000000000 --- a/Documentation/Examples/simple18 +++ /dev/null @@ -1,14 +0,0 @@ -arango> db.users.all().toArray(); -[ { "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285", "id" : 323, "name" : "Peter" }, - { "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749", "id" : 535, "name" : "Peter" }, - { "_id" : "users/554833357", "_key" : "554833357", "_rev" : "554833357", "id" : 25, "name" : "Vladimir" } ] - -arango> db.users.byExample({ "id" : 323 }).toArray(); -[ { "id" : 323, "name" : "Peter", "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285" } ] - -arango> db.users.byExample({ "name" : "Peter" }).toArray(); -[ { "id" : 323, "name" : "Peter", "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285" }, - { "id" : 535, "name" : "Peter", "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749" } ] - -arango> db.users.byExample({ "name" : "Peter", "id" : 535 }).toArray(); -[ { "id" : 535, "name" : "Peter", "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749" } ] diff --git a/Documentation/Examples/simple19 b/Documentation/Examples/simple19 deleted file mode 100644 index abf507fe9d..0000000000 --- a/Documentation/Examples/simple19 +++ /dev/null @@ -1,4 +0,0 @@ -arango> var a = db.users.byExample( {"name" : "Peter" } ); -arango> while (a.hasNext()) print(a.next()); -{ "id" : 323, "name" : "Peter", "_id" : "users/554702285", "_key" : "554702285", "_rev" : "554702285" } -{ "id" : 535, "name" : "Peter", "_id" : "users/554636749", "_key" : "554636749", "_rev" : "554636749" } diff --git a/Documentation/Examples/simple3 b/Documentation/Examples/simple3 deleted file mode 100644 index 1d23411454..0000000000 --- a/Documentation/Examples/simple3 +++ /dev/null @@ -1,8 +0,0 @@ -arango> db.five.all().toArray(); -[ - { "_id" : "five/1798296", "_key" : "1798296", "_rev" : "1798296", "doc" : 3 }, - { "_id" : "five/1732760", "_key" : "1732760", "_rev" : "1732760", "doc" : 2 }, - { "_id" : "five/1863832", "_key" : "1863832", "_rev" : "1863832", "doc" : 4 }, - { "_id" : "five/1667224", "_key" : "1667224", "_rev" : "1667224", "doc" : 1 }, - { "_id" : "five/1929368", "_key" : "1929368", "_rev" : "1929368", "doc" : 5 } -] diff --git a/Documentation/Examples/simple4 b/Documentation/Examples/simple4 deleted file mode 100644 index 203d5b3b9e..0000000000 --- a/Documentation/Examples/simple4 +++ /dev/null @@ -1,7 +0,0 @@ -arango> var a = db.five.all(); -arango> while (a.hasNext()) print(a.next()); -{ "_id" : "five/1798296", "_key" : "1798296", "_rev" : "1798296", "doc" : 3 } -{ "_id" : "five/1732760", "_key" : "1732760", "_rev" : "1732760", "doc" : 2 } -{ "_id" : "five/1863832", "_key" : "1863832", "_rev" : "1863832", "doc" : 4 } -{ "_id" : "five/1667224", "_key" : "1667224", "_rev" : "1667224", "doc" : 1 } -{ "_id" : "five/1929368", "_key" : "1929368", "_rev" : "1929368", "doc" : 5 } diff --git a/Documentation/Scripts/generateExamples.py b/Documentation/Scripts/generateExamples.py index afe1c8a797..9fa53ffc30 100644 --- a/Documentation/Scripts/generateExamples.py +++ b/Documentation/Scripts/generateExamples.py @@ -291,7 +291,7 @@ for filename in filenames: ### @brief generate arangosh example ################################################################################ -gr1 = re.compile(r'^[ \n]*(while|if|var) ') +gr1 = re.compile(r'^[ \n]*(while|if|var|throw|for) ') def generateArangoshOutput(): print "var internal = require('internal');" @@ -314,10 +314,12 @@ def generateArangoshOutput(): print "(function() {" print "internal.startCaptureMode();"; - print "try {" - print " var XXX;" + for l in value: + print "try {" + print " var XXX;" + m = gr1.match(l[0]) if l[1]: @@ -327,10 +329,12 @@ def generateArangoshOutput(): print "%s" % l[0] else: print "XXX = %s" % l[0] - print "if (XXX !== undefined) {print(XXX);}" + if l[1]: + print "if (XXX !== undefined) {print(XXX);}" - print "} catch (err) { print(err); }" - print "var output = internal.stopCaptureMode();"; + print "} catch (err) { print(err); }" + + print "var output = internal.stopCaptureMode();" print "ArangoshOutput['%s'] = output;" % key if JS_DEBUG: print "internal.output('%s', ':\\n', output, '\\n%s\\n');" % (key, '-' * 80) diff --git a/UnitTests/HttpInterface/api-general-graph-spec.rb b/UnitTests/HttpInterface/api-general-graph-spec.rb index cc3404f8c7..9d3e5466f9 100644 --- a/UnitTests/HttpInterface/api-general-graph-spec.rb +++ b/UnitTests/HttpInterface/api-general-graph-spec.rb @@ -20,6 +20,13 @@ def create_graph (name, edge_definitions) return doc end +def create_graph_orphans (name, edge_definitions, orphans) + cmd = URLPREFIX + body = JSON.dump({:name => name, :edgeDefinitions => edge_definitions, :orphanCollections => orphans}) + doc = ArangoDB.post(cmd, :body => body) + return doc +end + def vertex_endpoint(graph_name, collection) return URLPREFIX + "/" + graph_name + "/vertex/" + collection end @@ -194,6 +201,18 @@ describe ArangoDB do doc.parsed_response['graph']['edgeDefinitions'].should eq(edge_definition) end + it "can create a graph with orphan collections" do + orphans = [product_collection]; + doc = create_graph_orphans( graph_name, [], orphans) + doc.code.should eq(201) + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['graph']['name'].should eq(graph_name) + doc.parsed_response['graph']['_rev'].should eq(doc.headers['etag']) + doc.parsed_response['graph']['edgeDefinitions'].should eq([]) + doc.parsed_response['graph']['orphanCollections'].should eq(orphans) + end + it "can add additional edge definitions" do first_def = { "collection" => friend_collection, "from" => [user_collection], "to" => [user_collection] } edge_definition = [first_def] diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp index cd98c05840..04ce587b4d 100644 --- a/arangod/V8Server/v8-vocbase.cpp +++ b/arangod/V8Server/v8-vocbase.cpp @@ -5623,7 +5623,10 @@ static v8::Handle JS_LookupIndexVocbaseCol (v8::Arguments const& argv /// /// @EXAMPLES /// -/// @verbinclude shell-collection-count +/// @EXAMPLE_ARANGOSH_OUTPUT{HIER_FEHLT_DER_NAME} +/// db.users.count(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -5842,11 +5845,11 @@ static v8::Handle DropVocbaseColCoordinator (TRI_vocbase_col_t* colle /// @EXAMPLES /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionDrop} -/// ~ db._create("examples"); -/// col = db.examples; +/// ~ db._create("example"); +/// col = db.example; /// col.drop(); /// col; -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock @@ -6507,17 +6510,17 @@ static v8::Handle JS_PlanIdVocbaseCol (v8::Arguments const& argv) { /// Read all properties /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionProperties} -/// ~ db._create("examples"); -/// db.examples.properties(); -/// ~ db._drop("examples"); +/// ~ db._create("example"); +/// db.example.properties(); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// Change a property /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionProperty} -/// ~ db._create("examples"); -/// db.examples.properties({ waitForSync : false }); -/// ~ db._drop("examples"); +/// ~ db._create("example"); +/// db.example.properties({ waitForSync : false }); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock @@ -6782,38 +6785,28 @@ static v8::Handle JS_PropertiesVocbaseCol (v8::Arguments const& argv) /// /// Remove a document: /// -/// @code -/// arango> a1 = db.example.save({ a : 1 }); -/// { "_id" : "example/3449537", "_key" : "3449537", "_rev" : "3449537" } -/// arango> db.example.document(a1); -/// { "_id" : "example/3449537", "_key" : "3449537", "_rev" : "3449537", "a" : 1 } -/// arango> db.example.remove(a1); -/// true -/// arango> db.example.document(a1); -/// JavaScript exception in file '(arango)' at 1,12: [ArangoError 1202: document not found: document not found] -/// !db.example.document(a1); -/// ! ^ -/// @endcode +/// @EXAMPLE_ARANGOSH_OUTPUT{documentDocumentRemove} +/// ~ db._create("example"); +/// a1 = db.example.save({ a : 1 }); +/// db.example.document(a1); +/// db.example.remove(a1); +/// db.example.document(a1); +/// ~ db._drop("example"); +/// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// Remove a document with a conflict: /// -/// @code -/// arango> a1 = db.example.save({ a : 1 }); -/// { "_id" : "example/3857139", "_key" : "3857139", "_rev" : "3857139" } -/// arango> a2 = db.example.replace(a1, { a : 2 }); -/// { "_id" : "example/3857139", "_key" : "3857139", "_rev" : "3922675", "_oldRev" : 3857139 } -/// arango> db.example.remove(a1); -/// JavaScript exception in file '(arango)' at 1,18: [ArangoError 1200: conflict: cannot remove document] -/// !db.example.remove(a1); -/// ! ^ -/// arango> db.example.remove(a1, true); -/// true -/// arango> db.example.document(a1); -/// JavaScript exception in file '(arango)' at 1,12: [ArangoError 1202: document not found: document not found] -/// !db.example.document(a1); -/// ! ^ -/// @endcode -/// @endCodeBlock +/// @EXAMPLE_ARANGOSH_OUTPUT{documentDocumentRemoveConflict} +/// ~ db._create("example"); +/// a1 = db.example.save({ a : 1 }); +/// a2 = db.example.replace(a1, { a : 2 }); +/// db.example.remove(a1); +/// db.example.remove(a1, true); +/// db.example.document(a1); +/// ~ db._drop("example"); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// static v8::Handle JS_RemoveVocbaseCol (v8::Arguments const& argv) { @@ -6837,11 +6830,11 @@ static v8::Handle JS_RemoveVocbaseCol (v8::Arguments const& argv) { /// @EXAMPLES /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionRename} -/// ~ db._create("examples"); -/// c = db.examples; +/// ~ db._create("example"); +/// c = db.example; /// c.rename("better-example"); /// c; -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock @@ -7562,11 +7555,11 @@ static v8::Handle JS_TypeVocbaseCol (v8::Arguments const& argv) { /// @EXAMPLES /// /// @EXAMPLE_ARANGOSH_OUTPUT{CollectionUnload} -/// ~ db._create("examples"); -/// col = db.examples; +/// ~ db._create("example"); +/// col = db.example; /// col.unload(); /// col; -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock @@ -7667,9 +7660,9 @@ static v8::Handle WrapVocBase (TRI_vocbase_t const* database) { /// @EXAMPLES /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseCollectionName} -/// ~ db._create("examples"); -/// db.examples; -/// ~ db._drop("examples"); +/// ~ db._create("example"); +/// db.example; +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock @@ -7988,11 +7981,11 @@ static v8::Handle JS_CollectionVocbase (v8::Arguments const& argv) { /// @EXAMPLES /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionsDatabaseName} -/// ~ db._create("examples"); -/// db.examples.load(); +/// ~ db._create("example"); +/// db.example.load(); /// var d = db.demo; /// db._collections(); -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock @@ -8276,7 +8269,7 @@ static v8::Handle JS_CreateDocumentCollectionVocbase (v8::Arguments c /// /// @EXAMPLES /// -/// See @ref JS_CreateVocbase for examples. +/// See @ref JS_CreateVocbase for example. /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -8381,7 +8374,7 @@ static v8::Handle JS_RemoveVocbase (v8::Arguments const& argv) { /// identifier exists, or if the specified *_rev* value does not match the /// current revision of the document. /// -/// Please note that if the method is executed on the arangod server (e.g. from +/// **Note**: If the method is executed on the arangod server (e.g. from /// inside a Foxx application), an immutable document object will be returned /// for performance reasons. It is not possible to change attributes of this /// immutable object. To update or patch the returned document, it needs to be @@ -8398,7 +8391,13 @@ static v8::Handle JS_RemoveVocbase (v8::Arguments const& argv) { /// /// Returns the document: /// -/// @verbinclude shell_read-document-db +/// @EXAMPLE_ARANGOSH_OUTPUT{documentsDocumentName} +/// ~ db._create("example"); +/// ~ var myid = db.example.save({_key: "12345"}) +/// db._document("example/12345"); +/// ~ db._drop("example"); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -8472,7 +8471,14 @@ static v8::Handle JS_ExistsVocbase (v8::Arguments const& argv) { /// /// Create and replace a document: /// -/// @TINYEXAMPLE{shell_replace-document-db,replacing a document} +/// @EXAMPLE_ARANGOSH_OUTPUT{documentsDocumentReplace} +/// ~ db._create("example"); +/// a1 = db.example.save({ a : 1 }); +/// a2 = db._replace(a1, { a : 2 }); +/// a3 = db._replace(a1, { a : 3 }); +/// ~ db._drop("example"); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -8529,7 +8535,14 @@ static v8::Handle JS_ReplaceVocbase (v8::Arguments const& argv) { /// /// Create and update a document: /// -/// @TINYEXAMPLE{shell_update-document-db,updating a document} +/// @EXAMPLE_ARANGOSH_OUTPUT{documentDocumentUpdate} +/// ~ db._create("example"); +/// a1 = db.example.save({ a : 1 }); +/// a2 = db._update(a1, { b : 2 }); +/// a3 = db._update(a1, { c : 3 }); +/// ~ db._drop("example"); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/gharial/gharial.js b/js/apps/system/gharial/gharial.js index 81691ff16b..b03e0ac76d 100644 --- a/js/apps/system/gharial/gharial.js +++ b/js/apps/system/gharial/gharial.js @@ -128,7 +128,11 @@ */ controller.post("/", function(req, res) { var infos = req.params("graph"); - var g = Graph._create(infos.get("name"), infos.get("edgeDefinitions")); + var g = Graph._create( + infos.get("name"), + infos.get("edgeDefinitions"), + infos.get("orphanCollections") + ); setGraphResponse(res, g, actions.HTTP_CREATED); }).errorResponse( ArangoError, actions.HTTP_CONFLICT, "Graph creation error.", function(e) { diff --git a/js/client/modules/org/arangodb/arango-database.js b/js/client/modules/org/arangodb/arango-database.js index aaa48d6cc2..2573711ccb 100644 --- a/js/client/modules/org/arangodb/arango-database.js +++ b/js/client/modules/org/arangodb/arango-database.js @@ -386,6 +386,10 @@ ArangoDatabase.prototype._createEdgeCollection = function (name, properties) { ArangoDatabase.prototype._truncate = function (id) { var name; + if (typeof id !== "string") { + id = id._id; + } + for (name in this) { if (this.hasOwnProperty(name)) { var collection = this[name]; diff --git a/js/common/modules/org/arangodb/arango-collection-common.js b/js/common/modules/org/arangodb/arango-collection-common.js index 1aeecfcc03..2fbd4722fb 100644 --- a/js/common/modules/org/arangodb/arango-collection-common.js +++ b/js/common/modules/org/arangodb/arango-collection-common.js @@ -189,7 +189,7 @@ ArangoCollection.prototype.toString = function () { //////////////////////////////////////////////////////////////////////////////// /// @brief constructs an all query for a collection /// @startDocuBlock collectionAll -/// `all()` +/// `collection.all()` /// /// Selects all documents of a collection and returns a cursor. You can use /// *toArray*, *next*, or *hasNext* to access the result. The result @@ -199,11 +199,17 @@ ArangoCollection.prototype.toString = function () { /// /// Use *toArray* to get all documents at once: /// -/// @verbinclude simple3 +/// @EXAMPLE_ARANGOSH_OUTPUT{collectionAll} +/// db.five.all(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// Use *next* to loop over all documents: /// -/// @verbinclude simple4 +/// @EXAMPLE_ARANGOSH_OUTPUT{collectionAllNext} +/// var a = db.five.all().toArray(); +/// while (a.hasNext()) print(a.next()); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -260,11 +266,20 @@ ArangoCollection.prototype.all = function () { /// /// Use *toArray* to get all documents at once: /// -/// @TINYEXAMPLE{simple18,convert into a list} +/// @EXAMPLE_ARANGOSH_OUTPUT{collectionByExample} +/// db.users.all().toArray(); +/// db.users.byExample({ "id" : 323 }).toArray(); +/// db.users.byExample({ "name" : "Peter" }).toArray(); +/// db.users.byExample({ "name" : "Peter", "id" : 535 }).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// Use *next* to loop over all documents: /// -/// @TINYEXAMPLE{simple19,iterate over the result-set} +/// @EXAMPLE_ARANGOSH_OUTPUT{collectionByExampleNext} +/// var a = db.users.byExample( {"name" : "Peter" } ); +/// while (a.hasNext()) print(a.next()); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -496,7 +511,10 @@ ArangoCollection.prototype.byConditionBitarray = function (index, condition) { /// /// Use *toArray* to get all documents at once: /// -/// @TINYEXAMPLE{simple-query-range-to-array,convert into a list} +/// @EXAMPLE_ARANGOSH_OUTPUT{collectionRange} +/// l = db.skip.range("age", 10, 13).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/arango-collection.js b/js/server/modules/org/arangodb/arango-collection.js index 9aa723fefb..5634414d31 100644 --- a/js/server/modules/org/arangodb/arango-collection.js +++ b/js/server/modules/org/arangodb/arango-collection.js @@ -60,11 +60,12 @@ var ArangoDatabase = require("org/arangodb/arango-database").ArangoDatabase; //////////////////////////////////////////////////////////////////////////////// /// @brief converts collection into an array -/// -/// @FUN{@FA{collection}.toArray()} +/// @startDocuBlock collectionToArray +/// `collection.toArray()` /// /// Converts the collection into an array of documents. Never use this call /// in a production environment. +/// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// ArangoCollection.prototype.toArray = function () { @@ -94,13 +95,13 @@ ArangoCollection.prototype.toArray = function () { /// Truncates a collection: /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionTruncate} -/// ~ db._create("examples"); -/// col = db.examples; +/// ~ db._create("example"); +/// col = db.example; /// col.save({ "Hello" : "World" }); /// col.count(); /// col.truncate(); /// col.count(); -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -251,10 +252,11 @@ function getEdges (collection, vertex, direction) { //////////////////////////////////////////////////////////////////////////////// /// @brief returns all edges connected to a vertex +/// @startDocuBlock collectionEdgesAll +/// `collection.edges(vertex-id)` /// -/// @FUN{@FA{collection}.edges(@FA{vertex-id})} -/// -/// Returns all edges connected to the vertex specified by @FA{vertex-id}. +/// Returns all edges connected to the vertex specified by *vertex-id*. +/// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// ArangoCollection.prototype.edges = function (vertex) { @@ -263,10 +265,11 @@ ArangoCollection.prototype.edges = function (vertex) { //////////////////////////////////////////////////////////////////////////////// /// @brief returns inbound edges connected to a vertex +/// @startDocuBlock collectionEdgesInbound +/// `collection.edges(vertex-id)` /// -/// @FUN{@FA{collection}.edges(@FA{vertex-id})} -/// -/// Returns inbound edges connected to the vertex specified by @FA{vertex-id}. +/// Returns inbound edges connected to the vertex specified by *vertex-id*. +/// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// ArangoCollection.prototype.inEdges = function (vertex) { @@ -275,10 +278,11 @@ ArangoCollection.prototype.inEdges = function (vertex) { //////////////////////////////////////////////////////////////////////////////// /// @brief returns outbound edges connected to a vertex +/// @startDocuBlock collectionEdgesOutbound +/// `collection.edges(vertex-id)` /// -/// @FUN{@FA{collection}.edges(@FA{vertex-id})} -/// -/// Returns outbound edges connected to the vertex specified by @FA{vertex-id}. +/// Returns outbound edges connected to the vertex specified by *vertex-id*. +/// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// ArangoCollection.prototype.outEdges = function (vertex) { @@ -291,7 +295,7 @@ ArangoCollection.prototype.outEdges = function (vertex) { //////////////////////////////////////////////////////////////////////////////// /// @brief returns any document from a collection -/// @startDocuBlock documents_collectionAny +/// @startDocuBlock documentsCollectionAny /// `collection.any()` /// /// Returns a random document from the collection or *null* if none exists. @@ -335,7 +339,6 @@ ArangoCollection.prototype.any = function () { //////////////////////////////////////////////////////////////////////////////// /// @fn JSF_ArangoCollection_prototype_first -/// /// @brief selects the n first documents in the collection /// @startDocuBlock documentsCollectionFirst /// `collection.first(count)` @@ -354,20 +357,22 @@ ArangoCollection.prototype.any = function () { /// collection. If the collection does not contain any documents, the result /// returned is *null*. /// -/// Note: this method is not supported in sharded collections with more than +/// **Note**: this method is not supported in sharded collections with more than /// one shard. /// -/// *Examples* +/// @EXAMPLES /// -/// @code -/// arangod> db.example.first(1) -/// [ { "_id" : "example/222716379559", "_rev" : "222716379559", "Hello" : "World" } ] -/// @endcode +/// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionFirst} +/// ~ db._create("example"); +/// db.example.first(1) +/// ~ db._drop("example"); +/// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// @code -/// arangod> db.example.first() -/// { "_id" : "example/222716379559", "_rev" : "222716379559", "Hello" : "World" } -/// @endcode +/// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionFirstNull} +/// ~ db._create("example"); +/// arangod> db.example.first() +/// ~ db._drop("example"); +/// @END_EXAMPLE_ARANGOSH_OUTPUT /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -499,22 +504,25 @@ ArangoCollection.prototype.last = function (count) { //////////////////////////////////////////////////////////////////////////////// /// @fn JSF_ArangoCollection_prototype_firstExample -/// /// @brief constructs a query-by-example for a collection -/// -/// @FUN{@FA{collection}.firstExample(@FA{example})} +/// @startDocuBlock collectionFirstExample +/// `collection.firstExample(example)` /// /// Returns the first document of a collection that matches the specified -/// example or @LIT{null}. The example must be specified as paths and values. +/// example or *null*. The example must be specified as paths and values. /// See @FN{byExample} for details. /// -/// @FUN{@FA{collection}.firstExample(@FA{path1}, @FA{value1}, ...)} +/// `collection.firstExample(path1, value1, ...)` /// /// As alternative you can supply a list of paths and values. /// -/// *Examples* +/// @EXAMPLES /// -/// @TINYEXAMPLE{shell-simple-query-first-example,finds a document with a given name} +/// @EXAMPLE_ARANGOSH_OUTPUT{collectionFirstExample} +/// db.users.firstExample("name", 1237); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// ArangoCollection.prototype.firstExample = function (example) { diff --git a/js/server/modules/org/arangodb/arango-database.js b/js/server/modules/org/arangodb/arango-database.js index ea9a132cf9..95434126e1 100644 --- a/js/server/modules/org/arangodb/arango-database.js +++ b/js/server/modules/org/arangodb/arango-database.js @@ -212,21 +212,20 @@ ArangoDatabase.prototype._executeTransaction = function (data) { /// Drops a collection: /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseDrop} -/// ~ db._create("examples"); -/// col = db.examples; +/// ~ db._create("example"); +/// col = db.example; /// db._drop(col) /// col; -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// Drops a collection identified by name: /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseDropName} -/// ~ db._create("examples"); -/// col = db.examples; -/// db._drop("examples") +/// ~ db._create("example"); +/// col = db.example; +/// db._drop("example") /// col; -/// ~ db._drop("examples"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock @@ -269,25 +268,25 @@ ArangoDatabase.prototype._drop = function(name) { /// Truncates a collection: /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseTruncate} -/// ~ db._create("examples"); -/// col = db.examples; +/// ~ db._create("example"); +/// col = db.example; /// col.save({ "Hello" : "World" }); /// col.count(); /// db._truncate(col); /// col.count(); -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// Truncates a collection identified by name: /// /// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseTruncateName} -/// ~ db._create("examples"); -/// col = db.examples; +/// ~ db._create("example"); +/// col = db.example; /// col.save({ "Hello" : "World" }); /// col.count(); -/// db._truncate("examples"); +/// db._truncate("example"); /// col.count(); -/// ~ db._drop("examples"); +/// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock