mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
81a0180c8f
|
@ -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
|
Please note that several of these methods can be used from the _system
|
||||||
database only.
|
database only.
|
||||||
|
|
||||||
|
|
||||||
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||||
|
|
||||||
@startDocuBlock databaseName
|
@startDocuBlock databaseName
|
||||||
|
|
|
@ -1,163 +1,21 @@
|
||||||
!CHAPTER Database Methods
|
!CHAPTER Database Methods
|
||||||
|
|
||||||
`db._document( document)`
|
!SUBSECTION Document
|
||||||
|
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||||
|
@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
|
||||||
|
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||||
|
@startDocuBlock documentsDocumentExists
|
||||||
|
|
||||||
An error is thrown if the _rev does not longer match the current revision of the document.
|
!SUBSECTION Replace
|
||||||
|
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||||
|
@startDocuBlock documentsDocumentReplace
|
||||||
|
|
||||||
`db._document( document-handle)`
|
!SUBSECTION Update
|
||||||
|
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||||
|
@startDocuBlock documentsDocumentUpdate
|
||||||
|
|
||||||
As before. Instead of document a document-handle can be passed as first argument.
|
!SUBSECTION Remove
|
||||||
|
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||||
*Examples*
|
@startDocuBlock documentsDocumentRemove
|
||||||
|
|
||||||
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);
|
|
||||||
! ^
|
|
||||||
|
|
||||||
<!--
|
|
||||||
@anchor HandlingDocumentsDbRead
|
|
||||||
@copydetails JS_DocumentVocbase
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor HandlingDocumentsDbExists
|
|
||||||
@copydetails JS_ExistsVocbase
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor HandlingDocumentsDbReplace
|
|
||||||
@copydetails JS_ReplaceVocbase
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor HandlingDocumentsDbUpdate
|
|
||||||
@copydetails JS_UpdateVocbase
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor HandlingDocumentsDbRemove
|
|
||||||
@copydetails JS_RemoveVocbase
|
|
||||||
|
|
||||||
@BNAVIGATE_HandlingDocuments
|
|
||||||
-->
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ documents of a collection as:
|
||||||
|
|
||||||
db.collection.document("document-handle")
|
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
|
of the document, is *demo/362549* and the document lives in a collection
|
||||||
named *demo*, then that document can be accessed as:
|
named *demo*, then that document can be accessed as:
|
||||||
|
|
||||||
|
|
|
@ -1,185 +1,42 @@
|
||||||
!CHAPTER Collection Methods
|
!CHAPTER Collection Methods
|
||||||
|
|
||||||
`collection.all()`
|
!SUBSECTION All
|
||||||
|
<!-- js/common/modules/org/arangodb/arango-collection-common.js-->
|
||||||
|
@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
|
||||||
|
<!-- js/common/modules/org/arangodb/arango-collection-common.js-->
|
||||||
|
@startDocuBlock collectionByExample
|
||||||
|
|
||||||
*Examples*
|
!SUBSECTION First Example
|
||||||
|
<!-- js/server/modules/org/arangodb/arango-collection.js-->
|
||||||
|
@startDocuBlock collectionFirstExample
|
||||||
|
|
||||||
Use toArray to get all documents at once:
|
!SUBSECTION Range
|
||||||
|
<!-- js/common/modules/org/arangodb/arango-collection-common.js-->
|
||||||
|
@startDocuBlock collectionRange
|
||||||
|
|
||||||
arango> db.five.all().toArray();
|
!SUBSECTION Any
|
||||||
[
|
<!-- js/server/modules/org/arangodb/arango-collection.js-->
|
||||||
{ "_id" : "five/1798296", "_key" : "1798296", "_rev" : "1798296", "doc" : 3 },
|
@startDocuBlock documentsCollectionAny
|
||||||
{ "_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 }
|
|
||||||
]
|
|
||||||
|
|
||||||
Use next to loop over all documents:
|
!SUBSECTION Count
|
||||||
|
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||||
|
@startDocuBlock colllectionCount
|
||||||
|
|
||||||
arango> var a = db.five.all();
|
!SUBSECTION toArray
|
||||||
arango> while (a.hasNext()) print(a.next());
|
<!-- js/server/modules/org/arangodb/arango-collection.js-->
|
||||||
{ "_id" : "five/1798296", "_key" : "1798296", "_rev" : "1798296", "doc" : 3 }
|
@startDocuBlock collectionToArray
|
||||||
{ "_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 }
|
|
||||||
|
|
||||||
`collection.byExample( example)`
|
!SUBSECTION First
|
||||||
|
<!-- js/server/modules/org/arangodb/arango-collection.js-->
|
||||||
|
@startDocuBlock documentsCollectionFirst
|
||||||
|
|
||||||
Selects all documents of a collection that match the specified example and returns a cursor.
|
!SUBSECTION Last
|
||||||
|
<!-- js/server/modules/org/arangodb/arango-collection.js-->
|
||||||
|
@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.
|
|
||||||
|
|
||||||
<!--
|
|
||||||
@anchor SimpleQueryAll
|
|
||||||
@copydetails JSF_ArangoCollection_prototype_all
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryByExample
|
|
||||||
@copydetails JSF_ArangoCollection_prototype_byExample
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryFirstExample
|
|
||||||
@copydetails JSF_ArangoCollection_prototype_firstExample
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryAny
|
|
||||||
@copydetails JSF_ArangoCollection_prototype_range
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryRange
|
|
||||||
@copydetails JS_AnyQuery
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryCollectionCount
|
|
||||||
@copydetails JS_CountVocbaseCol
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryToArray
|
|
||||||
@copydetails JSF_ArangoCollection_prototype_toArray
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryFirst
|
|
||||||
@copydetails JSF_ArangoCollection_prototype_first
|
|
||||||
|
|
||||||
@CLEARPAGE
|
|
||||||
@anchor SimpleQueryLast
|
|
||||||
@copydetails JSF_ArangoCollection_prototype_last
|
|
||||||
-->
|
|
||||||
|
|
||||||
`collection.document( document)`
|
`collection.document( document)`
|
||||||
|
|
||||||
|
|
|
@ -10,29 +10,24 @@ and may contain lists. Each document is uniquely identified by its document hand
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
{
|
```js
|
||||||
"firstName" : "Hugo",
|
{
|
||||||
"lastName" : "Schlonz",
|
"firstName" : "Hugo",
|
||||||
"address" : {
|
"lastName" : "Schlonz",
|
||||||
"city" : "Hier",
|
"address" : {
|
||||||
"street" : "Strasse 1"
|
"city" : "Hier",
|
||||||
},
|
"street" : "Strasse 1"
|
||||||
"hobbies" : [
|
},
|
||||||
"swimming",
|
"hobbies" : [
|
||||||
"biking",
|
"swimming",
|
||||||
"programming"
|
"biking",
|
||||||
],
|
"programming"
|
||||||
"_id" : "demo/schlonz",
|
],
|
||||||
"_rev" : "13728680",
|
"_id" : "demo/schlonz",
|
||||||
"_key" : "schlonz"
|
"_rev" : "13728680",
|
||||||
}
|
"_key" : "schlonz"
|
||||||
|
}
|
||||||
<!--
|
```
|
||||||
@EXAMPLE_ARANGOSH_OUTPUT{HandlingDocumentsExample1}
|
|
||||||
db.demo.document("demo/schlonz")
|
|
||||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
||||||
-->
|
|
||||||
|
|
||||||
All documents contain special attributes: the document handle in *_id*, the
|
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
|
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
|
*_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,
|
comparisons with them to check if a document revision is older than one another,
|
||||||
even if this might work for some cases.
|
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.
|
returned by several HTTP API methods in the Etag HTTP header.
|
||||||
|
|
|
@ -15,7 +15,7 @@ definition, at least one is needed.
|
||||||
@RESTHEADER{GET /_api/gharial, List all graphs}
|
@RESTHEADER{GET /_api/gharial, List all graphs}
|
||||||
|
|
||||||
@RESTDESCRIPTION
|
@RESTDESCRIPTION
|
||||||
Lists all graph names stored in this database.
|
Lists all graph names stored in this database.ssss
|
||||||
|
|
||||||
@RESTRETURNCODES
|
@RESTRETURNCODES
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,6 @@ def getTextFromSourceFile(searchText, full_path):
|
||||||
if match:
|
if match:
|
||||||
textExtracted = match.group(1)
|
textExtracted = match.group(1)
|
||||||
textExtracted = textExtracted.replace("<br />","\n")
|
textExtracted = textExtracted.replace("<br />","\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)
|
replaceText(textExtracted, full_path, searchText)
|
||||||
|
|
||||||
def replaceText(text, pathOfFile, searchText):
|
def replaceText(text, pathOfFile, searchText):
|
||||||
|
@ -42,11 +36,28 @@ def replaceText(text, pathOfFile, searchText):
|
||||||
f.close()
|
f.close()
|
||||||
f=open(pathOfFile,'w')
|
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.write(replaced)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
path = ["Documentation/Books/Users"]
|
path = ["Documentation/Books/Users"]
|
||||||
for i in path:
|
for i in path:
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db.users.count();
|
|
||||||
10001
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db.users.firstExample("name", 1237);
|
|
||||||
{ "_id" : "users/83049373", "_key" : "83049373", "_rev" : "83049373", "name" : 1237 }
|
|
|
@ -1,5 +0,0 @@
|
||||||
arango> col = db.examples;
|
|
||||||
[ArangoCollection 109757, "examples" (status unloaded)]
|
|
||||||
arango> col.drop()
|
|
||||||
arango> col;
|
|
||||||
[ArangoCollection 109757, "examples" (status deleted)]
|
|
|
@ -1,5 +0,0 @@
|
||||||
arango> col = db.examples;
|
|
||||||
[ArangoCollection 109757, "examples" (status unloaded)]
|
|
||||||
arango> db._drop(col)
|
|
||||||
arango> col;
|
|
||||||
[ArangoCollection 109757, "examples" (status deleted)]
|
|
|
@ -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)]
|
|
|
@ -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 } }
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db.examples.properties()
|
|
||||||
{ "waitForSync" : false, "journalSize" : 33554432, "isVolatile" : false }
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db.examples.properties({ waitForSync : false })
|
|
||||||
{ "waitForSync" : false, "journalSize" : 33554432, "isVolatile" : false }
|
|
|
@ -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)]
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -1,5 +0,0 @@
|
||||||
arango> col = db.example;
|
|
||||||
[ArangoCollection 164208316, "example" (status loaded)]
|
|
||||||
arango> col.unload();
|
|
||||||
arango> col;
|
|
||||||
[ArangoCollection 164208316, "example" (status unloaded)]
|
|
|
@ -1,4 +0,0 @@
|
||||||
arango> c = db._create("cars");
|
|
||||||
[ArangoCollection 111137, "cars" (status loaded)]
|
|
||||||
arango> c.properties()
|
|
||||||
{ "waitForSync" : false, "journalSize" : 33554432, "isVolatile" : false }
|
|
|
@ -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" }
|
|
|
@ -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
|
|
|
@ -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 }
|
|
|
@ -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)]]
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db._collection(145387);
|
|
||||||
[ArangoCollection 145387, "demo" (status loaded)]
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db._collection("demo");
|
|
||||||
[ArangoCollection 145387, "demo" (status loaded)]
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db.examples;
|
|
||||||
[ArangoCollection 110371, "examples" (status new born)]
|
|
|
@ -1,2 +0,0 @@
|
||||||
arango> db._collection("unknown")
|
|
||||||
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 }
|
|
||||||
]
|
|
|
@ -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" } ]
|
|
|
@ -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" }
|
|
|
@ -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 }
|
|
||||||
]
|
|
|
@ -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 }
|
|
|
@ -291,7 +291,7 @@ for filename in filenames:
|
||||||
### @brief generate arangosh example
|
### @brief generate arangosh example
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
gr1 = re.compile(r'^[ \n]*(while|if|var) ')
|
gr1 = re.compile(r'^[ \n]*(while|if|var|throw|for) ')
|
||||||
|
|
||||||
def generateArangoshOutput():
|
def generateArangoshOutput():
|
||||||
print "var internal = require('internal');"
|
print "var internal = require('internal');"
|
||||||
|
@ -314,10 +314,12 @@ def generateArangoshOutput():
|
||||||
|
|
||||||
print "(function() {"
|
print "(function() {"
|
||||||
print "internal.startCaptureMode();";
|
print "internal.startCaptureMode();";
|
||||||
print "try {"
|
|
||||||
print " var XXX;"
|
|
||||||
|
|
||||||
for l in value:
|
for l in value:
|
||||||
|
print "try {"
|
||||||
|
print " var XXX;"
|
||||||
|
|
||||||
m = gr1.match(l[0])
|
m = gr1.match(l[0])
|
||||||
|
|
||||||
if l[1]:
|
if l[1]:
|
||||||
|
@ -327,10 +329,12 @@ def generateArangoshOutput():
|
||||||
print "%s" % l[0]
|
print "%s" % l[0]
|
||||||
else:
|
else:
|
||||||
print "XXX = %s" % l[0]
|
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 "} catch (err) { print(err); }"
|
||||||
print "var output = internal.stopCaptureMode();";
|
|
||||||
|
print "var output = internal.stopCaptureMode();"
|
||||||
print "ArangoshOutput['%s'] = output;" % key
|
print "ArangoshOutput['%s'] = output;" % key
|
||||||
if JS_DEBUG:
|
if JS_DEBUG:
|
||||||
print "internal.output('%s', ':\\n', output, '\\n%s\\n');" % (key, '-' * 80)
|
print "internal.output('%s', ':\\n', output, '\\n%s\\n');" % (key, '-' * 80)
|
||||||
|
|
|
@ -20,6 +20,13 @@ def create_graph (name, edge_definitions)
|
||||||
return doc
|
return doc
|
||||||
end
|
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)
|
def vertex_endpoint(graph_name, collection)
|
||||||
return URLPREFIX + "/" + graph_name + "/vertex/" + collection
|
return URLPREFIX + "/" + graph_name + "/vertex/" + collection
|
||||||
end
|
end
|
||||||
|
@ -194,6 +201,18 @@ describe ArangoDB do
|
||||||
doc.parsed_response['graph']['edgeDefinitions'].should eq(edge_definition)
|
doc.parsed_response['graph']['edgeDefinitions'].should eq(edge_definition)
|
||||||
end
|
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
|
it "can add additional edge definitions" do
|
||||||
first_def = { "collection" => friend_collection, "from" => [user_collection], "to" => [user_collection] }
|
first_def = { "collection" => friend_collection, "from" => [user_collection], "to" => [user_collection] }
|
||||||
edge_definition = [first_def]
|
edge_definition = [first_def]
|
||||||
|
|
|
@ -5623,7 +5623,10 @@ static v8::Handle<v8::Value> JS_LookupIndexVocbaseCol (v8::Arguments const& argv
|
||||||
///
|
///
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @verbinclude shell-collection-count
|
/// @EXAMPLE_ARANGOSH_OUTPUT{HIER_FEHLT_DER_NAME}
|
||||||
|
/// db.users.count();
|
||||||
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -5842,11 +5845,11 @@ static v8::Handle<v8::Value> DropVocbaseColCoordinator (TRI_vocbase_col_t* colle
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDrop}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDrop}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// col = db.examples;
|
/// col = db.example;
|
||||||
/// col.drop();
|
/// col.drop();
|
||||||
/// col;
|
/// col;
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
@ -6507,17 +6510,17 @@ static v8::Handle<v8::Value> JS_PlanIdVocbaseCol (v8::Arguments const& argv) {
|
||||||
/// Read all properties
|
/// Read all properties
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionProperties}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionProperties}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// db.examples.properties();
|
/// db.example.properties();
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// Change a property
|
/// Change a property
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionProperty}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionProperty}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// db.examples.properties({ waitForSync : false });
|
/// db.example.properties({ waitForSync : false });
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
@ -6782,38 +6785,28 @@ static v8::Handle<v8::Value> JS_PropertiesVocbaseCol (v8::Arguments const& argv)
|
||||||
///
|
///
|
||||||
/// Remove a document:
|
/// Remove a document:
|
||||||
///
|
///
|
||||||
/// @code
|
/// @EXAMPLE_ARANGOSH_OUTPUT{documentDocumentRemove}
|
||||||
/// arango> a1 = db.example.save({ a : 1 });
|
/// ~ db._create("example");
|
||||||
/// { "_id" : "example/3449537", "_key" : "3449537", "_rev" : "3449537" }
|
/// a1 = db.example.save({ a : 1 });
|
||||||
/// arango> db.example.document(a1);
|
/// db.example.document(a1);
|
||||||
/// { "_id" : "example/3449537", "_key" : "3449537", "_rev" : "3449537", "a" : 1 }
|
/// db.example.remove(a1);
|
||||||
/// arango> db.example.remove(a1);
|
/// db.example.document(a1);
|
||||||
/// true
|
/// ~ db._drop("example");
|
||||||
/// arango> db.example.document(a1);
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
/// JavaScript exception in file '(arango)' at 1,12: [ArangoError 1202: document not found: document not found]
|
|
||||||
/// !db.example.document(a1);
|
|
||||||
/// ! ^
|
|
||||||
/// @endcode
|
|
||||||
///
|
///
|
||||||
/// Remove a document with a conflict:
|
/// Remove a document with a conflict:
|
||||||
///
|
///
|
||||||
/// @code
|
/// @EXAMPLE_ARANGOSH_OUTPUT{documentDocumentRemoveConflict}
|
||||||
/// arango> a1 = db.example.save({ a : 1 });
|
/// ~ db._create("example");
|
||||||
/// { "_id" : "example/3857139", "_key" : "3857139", "_rev" : "3857139" }
|
/// a1 = db.example.save({ a : 1 });
|
||||||
/// arango> a2 = db.example.replace(a1, { a : 2 });
|
/// a2 = db.example.replace(a1, { a : 2 });
|
||||||
/// { "_id" : "example/3857139", "_key" : "3857139", "_rev" : "3922675", "_oldRev" : 3857139 }
|
/// db.example.remove(a1);
|
||||||
/// arango> db.example.remove(a1);
|
/// db.example.remove(a1, true);
|
||||||
/// JavaScript exception in file '(arango)' at 1,18: [ArangoError 1200: conflict: cannot remove document]
|
/// db.example.document(a1);
|
||||||
/// !db.example.remove(a1);
|
/// ~ db._drop("example");
|
||||||
/// ! ^
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
/// arango> db.example.remove(a1, true);
|
///
|
||||||
/// true
|
/// @endDocuBlock
|
||||||
/// 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
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static v8::Handle<v8::Value> JS_RemoveVocbaseCol (v8::Arguments const& argv) {
|
static v8::Handle<v8::Value> JS_RemoveVocbaseCol (v8::Arguments const& argv) {
|
||||||
|
@ -6837,11 +6830,11 @@ static v8::Handle<v8::Value> JS_RemoveVocbaseCol (v8::Arguments const& argv) {
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionRename}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionRename}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// c = db.examples;
|
/// c = db.example;
|
||||||
/// c.rename("better-example");
|
/// c.rename("better-example");
|
||||||
/// c;
|
/// c;
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
@ -7562,11 +7555,11 @@ static v8::Handle<v8::Value> JS_TypeVocbaseCol (v8::Arguments const& argv) {
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{CollectionUnload}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{CollectionUnload}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// col = db.examples;
|
/// col = db.example;
|
||||||
/// col.unload();
|
/// col.unload();
|
||||||
/// col;
|
/// col;
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
@ -7667,9 +7660,9 @@ static v8::Handle<v8::Object> WrapVocBase (TRI_vocbase_t const* database) {
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseCollectionName}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseCollectionName}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// db.examples;
|
/// db.example;
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
@ -7988,11 +7981,11 @@ static v8::Handle<v8::Value> JS_CollectionVocbase (v8::Arguments const& argv) {
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionsDatabaseName}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionsDatabaseName}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// db.examples.load();
|
/// db.example.load();
|
||||||
/// var d = db.demo;
|
/// var d = db.demo;
|
||||||
/// db._collections();
|
/// db._collections();
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
@ -8276,7 +8269,7 @@ static v8::Handle<v8::Value> JS_CreateDocumentCollectionVocbase (v8::Arguments c
|
||||||
///
|
///
|
||||||
/// @EXAMPLES
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// See @ref JS_CreateVocbase for examples.
|
/// See @ref JS_CreateVocbase for example.
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -8381,7 +8374,7 @@ static v8::Handle<v8::Value> JS_RemoveVocbase (v8::Arguments const& argv) {
|
||||||
/// identifier exists, or if the specified *_rev* value does not match the
|
/// identifier exists, or if the specified *_rev* value does not match the
|
||||||
/// current revision of the document.
|
/// 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
|
/// inside a Foxx application), an immutable document object will be returned
|
||||||
/// for performance reasons. It is not possible to change attributes of this
|
/// 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
|
/// immutable object. To update or patch the returned document, it needs to be
|
||||||
|
@ -8398,7 +8391,13 @@ static v8::Handle<v8::Value> JS_RemoveVocbase (v8::Arguments const& argv) {
|
||||||
///
|
///
|
||||||
/// Returns the document:
|
/// 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
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -8472,7 +8471,14 @@ static v8::Handle<v8::Value> JS_ExistsVocbase (v8::Arguments const& argv) {
|
||||||
///
|
///
|
||||||
/// Create and replace a document:
|
/// 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
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -8529,7 +8535,14 @@ static v8::Handle<v8::Value> JS_ReplaceVocbase (v8::Arguments const& argv) {
|
||||||
///
|
///
|
||||||
/// Create and update a document:
|
/// 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
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,11 @@
|
||||||
*/
|
*/
|
||||||
controller.post("/", function(req, res) {
|
controller.post("/", function(req, res) {
|
||||||
var infos = req.params("graph");
|
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);
|
setGraphResponse(res, g, actions.HTTP_CREATED);
|
||||||
}).errorResponse(
|
}).errorResponse(
|
||||||
ArangoError, actions.HTTP_CONFLICT, "Graph creation error.", function(e) {
|
ArangoError, actions.HTTP_CONFLICT, "Graph creation error.", function(e) {
|
||||||
|
|
|
@ -386,6 +386,10 @@ ArangoDatabase.prototype._createEdgeCollection = function (name, properties) {
|
||||||
ArangoDatabase.prototype._truncate = function (id) {
|
ArangoDatabase.prototype._truncate = function (id) {
|
||||||
var name;
|
var name;
|
||||||
|
|
||||||
|
if (typeof id !== "string") {
|
||||||
|
id = id._id;
|
||||||
|
}
|
||||||
|
|
||||||
for (name in this) {
|
for (name in this) {
|
||||||
if (this.hasOwnProperty(name)) {
|
if (this.hasOwnProperty(name)) {
|
||||||
var collection = this[name];
|
var collection = this[name];
|
||||||
|
|
|
@ -189,7 +189,7 @@ ArangoCollection.prototype.toString = function () {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief constructs an all query for a collection
|
/// @brief constructs an all query for a collection
|
||||||
/// @startDocuBlock collectionAll
|
/// @startDocuBlock collectionAll
|
||||||
/// `all()`
|
/// `collection.all()`
|
||||||
///
|
///
|
||||||
/// Selects all documents of a collection and returns a cursor. You can use
|
/// Selects all documents of a collection and returns a cursor. You can use
|
||||||
/// *toArray*, *next*, or *hasNext* to access the result. The result
|
/// *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:
|
/// 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:
|
/// 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
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -260,11 +266,20 @@ ArangoCollection.prototype.all = function () {
|
||||||
///
|
///
|
||||||
/// Use *toArray* to get all documents at once:
|
/// 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:
|
/// 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
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -496,7 +511,10 @@ ArangoCollection.prototype.byConditionBitarray = function (index, condition) {
|
||||||
///
|
///
|
||||||
/// Use *toArray* to get all documents at once:
|
/// 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
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -60,11 +60,12 @@ var ArangoDatabase = require("org/arangodb/arango-database").ArangoDatabase;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief converts collection into an array
|
/// @brief converts collection into an array
|
||||||
///
|
/// @startDocuBlock collectionToArray
|
||||||
/// @FUN{@FA{collection}.toArray()}
|
/// `collection.toArray()`
|
||||||
///
|
///
|
||||||
/// Converts the collection into an array of documents. Never use this call
|
/// Converts the collection into an array of documents. Never use this call
|
||||||
/// in a production environment.
|
/// in a production environment.
|
||||||
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ArangoCollection.prototype.toArray = function () {
|
ArangoCollection.prototype.toArray = function () {
|
||||||
|
@ -94,13 +95,13 @@ ArangoCollection.prototype.toArray = function () {
|
||||||
/// Truncates a collection:
|
/// Truncates a collection:
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionTruncate}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionTruncate}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// col = db.examples;
|
/// col = db.example;
|
||||||
/// col.save({ "Hello" : "World" });
|
/// col.save({ "Hello" : "World" });
|
||||||
/// col.count();
|
/// col.count();
|
||||||
/// col.truncate();
|
/// col.truncate();
|
||||||
/// col.count();
|
/// col.count();
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -251,10 +252,11 @@ function getEdges (collection, vertex, direction) {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief returns all edges connected to a vertex
|
/// @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 *vertex-id*.
|
||||||
///
|
/// @endDocuBlock
|
||||||
/// Returns all edges connected to the vertex specified by @FA{vertex-id}.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ArangoCollection.prototype.edges = function (vertex) {
|
ArangoCollection.prototype.edges = function (vertex) {
|
||||||
|
@ -263,10 +265,11 @@ ArangoCollection.prototype.edges = function (vertex) {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief returns inbound edges connected to a 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 *vertex-id*.
|
||||||
///
|
/// @endDocuBlock
|
||||||
/// Returns inbound edges connected to the vertex specified by @FA{vertex-id}.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ArangoCollection.prototype.inEdges = function (vertex) {
|
ArangoCollection.prototype.inEdges = function (vertex) {
|
||||||
|
@ -275,10 +278,11 @@ ArangoCollection.prototype.inEdges = function (vertex) {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief returns outbound edges connected to a 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 *vertex-id*.
|
||||||
///
|
/// @endDocuBlock
|
||||||
/// Returns outbound edges connected to the vertex specified by @FA{vertex-id}.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ArangoCollection.prototype.outEdges = function (vertex) {
|
ArangoCollection.prototype.outEdges = function (vertex) {
|
||||||
|
@ -291,7 +295,7 @@ ArangoCollection.prototype.outEdges = function (vertex) {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief returns any document from a collection
|
/// @brief returns any document from a collection
|
||||||
/// @startDocuBlock documents_collectionAny
|
/// @startDocuBlock documentsCollectionAny
|
||||||
/// `collection.any()`
|
/// `collection.any()`
|
||||||
///
|
///
|
||||||
/// Returns a random document from the collection or *null* if none exists.
|
/// 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
|
/// @fn JSF_ArangoCollection_prototype_first
|
||||||
///
|
|
||||||
/// @brief selects the n first documents in the collection
|
/// @brief selects the n first documents in the collection
|
||||||
/// @startDocuBlock documentsCollectionFirst
|
/// @startDocuBlock documentsCollectionFirst
|
||||||
/// `collection.first(count)`
|
/// `collection.first(count)`
|
||||||
|
@ -354,20 +357,22 @@ ArangoCollection.prototype.any = function () {
|
||||||
/// collection. If the collection does not contain any documents, the result
|
/// collection. If the collection does not contain any documents, the result
|
||||||
/// returned is *null*.
|
/// 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.
|
/// one shard.
|
||||||
///
|
///
|
||||||
/// *Examples*
|
/// @EXAMPLES
|
||||||
///
|
///
|
||||||
/// @code
|
/// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionFirst}
|
||||||
/// arangod> db.example.first(1)
|
/// ~ db._create("example");
|
||||||
/// [ { "_id" : "example/222716379559", "_rev" : "222716379559", "Hello" : "World" } ]
|
/// db.example.first(1)
|
||||||
/// @endcode
|
/// ~ db._drop("example");
|
||||||
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @code
|
/// @EXAMPLE_ARANGOSH_OUTPUT{documentsCollectionFirstNull}
|
||||||
/// arangod> db.example.first()
|
/// ~ db._create("example");
|
||||||
/// { "_id" : "example/222716379559", "_rev" : "222716379559", "Hello" : "World" }
|
/// arangod> db.example.first()
|
||||||
/// @endcode
|
/// ~ db._drop("example");
|
||||||
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -499,22 +504,25 @@ ArangoCollection.prototype.last = function (count) {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @fn JSF_ArangoCollection_prototype_firstExample
|
/// @fn JSF_ArangoCollection_prototype_firstExample
|
||||||
///
|
|
||||||
/// @brief constructs a query-by-example for a collection
|
/// @brief constructs a query-by-example for a collection
|
||||||
///
|
/// @startDocuBlock collectionFirstExample
|
||||||
/// @FUN{@FA{collection}.firstExample(@FA{example})}
|
/// `collection.firstExample(example)`
|
||||||
///
|
///
|
||||||
/// Returns the first document of a collection that matches the specified
|
/// 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.
|
/// 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.
|
/// 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) {
|
ArangoCollection.prototype.firstExample = function (example) {
|
||||||
|
|
|
@ -212,21 +212,20 @@ ArangoDatabase.prototype._executeTransaction = function (data) {
|
||||||
/// Drops a collection:
|
/// Drops a collection:
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseDrop}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseDrop}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// col = db.examples;
|
/// col = db.example;
|
||||||
/// db._drop(col)
|
/// db._drop(col)
|
||||||
/// col;
|
/// col;
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// Drops a collection identified by name:
|
/// Drops a collection identified by name:
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseDropName}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseDropName}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// col = db.examples;
|
/// col = db.example;
|
||||||
/// db._drop("examples")
|
/// db._drop("example")
|
||||||
/// col;
|
/// col;
|
||||||
/// ~ db._drop("examples");
|
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
@ -269,25 +268,25 @@ ArangoDatabase.prototype._drop = function(name) {
|
||||||
/// Truncates a collection:
|
/// Truncates a collection:
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseTruncate}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseTruncate}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// col = db.examples;
|
/// col = db.example;
|
||||||
/// col.save({ "Hello" : "World" });
|
/// col.save({ "Hello" : "World" });
|
||||||
/// col.count();
|
/// col.count();
|
||||||
/// db._truncate(col);
|
/// db._truncate(col);
|
||||||
/// col.count();
|
/// col.count();
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// Truncates a collection identified by name:
|
/// Truncates a collection identified by name:
|
||||||
///
|
///
|
||||||
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseTruncateName}
|
/// @EXAMPLE_ARANGOSH_OUTPUT{collectionDatabaseTruncateName}
|
||||||
/// ~ db._create("examples");
|
/// ~ db._create("example");
|
||||||
/// col = db.examples;
|
/// col = db.example;
|
||||||
/// col.save({ "Hello" : "World" });
|
/// col.save({ "Hello" : "World" });
|
||||||
/// col.count();
|
/// col.count();
|
||||||
/// db._truncate("examples");
|
/// db._truncate("example");
|
||||||
/// col.count();
|
/// col.count();
|
||||||
/// ~ db._drop("examples");
|
/// ~ db._drop("example");
|
||||||
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
///
|
///
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
|
|
Loading…
Reference in New Issue