33The _ EdgeCollection API_ extends the
44[ _ Collection API_ ] ( README.md ) with the following methods.
55
6- ## edgeCollection.edge
6+ ## edgeCollection.document
77
8- ` async edgeCollection.edge(documentHandle): Object `
8+ ` async edgeCollection.document(documentHandle, [graceful]): Object `
9+
10+ Alias: ` edgeCollection.edge ` .
911
1012Retrieves the edge with the given _ documentHandle_ from the collection.
1113
1214** Arguments**
1315
14- * ** documentHandle** : ` string `
16+ - ** documentHandle** : ` string `
1517
1618 The handle of the edge to retrieve. This can be either the ` _id ` or the ` _key `
1719 of an edge in the collection, or an edge (i.e. an object with an ` _id ` or
1820 ` _key ` property).
1921
22+ * ** graceful** : ` boolean ` (Default: ` false ` )
23+
24+ If set to ` true ` , the method will return ` null ` instead of throwing an error
25+ if the edge does not exist.
26+
2027** Examples**
2128
2229``` js
2330const db = new Database ();
2431const collection = db .edgeCollection (' edges' );
2532
26- const edge = await collection .edge (' some-key' );
33+ const edge = await collection .document (' some-key' );
2734// the edge exists
2835assert .equal (edge ._key , ' some-key' );
2936assert .equal (edge ._id , ' edges/some-key' );
3037
3138// -- or --
3239
33- const edge = await collection .edge (' edges/some-key' );
40+ const edge = await collection .document (' edges/some-key' );
3441// the edge exists
3542assert .equal (edge ._key , ' some-key' );
3643assert .equal (edge ._id , ' edges/some-key' );
44+
45+ // -- or --
46+
47+ const edge = await collection .document (' some-key' , true );
48+ if (edge === null ) {
49+ // the edge does not exist
50+ }
51+ ```
52+
53+ ## edgeCollection.documentExists
54+
55+ ` async edgeCollection.documentExists(documentHandle): boolean `
56+
57+ Checks whether the edge with the given _ documentHandle_ exists.
58+
59+ ** Arguments**
60+
61+ - ** documentHandle** : ` string `
62+
63+ The handle of the edge to retrieve. This can be either the ` _id ` or the
64+ ` _key ` of a edge in the collection, or an edge (i.e. an object with an
65+ ` _id ` or ` _key ` property).
66+
67+ ** Examples**
68+
69+ ``` js
70+ const db = new Database ();
71+ const collection = db .edgeCollection (' my-docs' );
72+
73+ const exists = await collection .documentExists (' some-key' );
74+ if (exists === false ) {
75+ // the edge does not exist
76+ }
3777```
3878
3979## edgeCollection.save
@@ -45,51 +85,51 @@ _data_ and returns an object containing the edge's metadata.
4585
4686** Arguments**
4787
48- * ** data** : ` Object `
88+ - ** data** : ` Object `
4989
5090 The data of the new edge. If _ fromId_ and _ toId_ are not specified, the _ data_
5191 needs to contain the properties ` _from ` and ` _to ` .
5292
53- * ** fromId** : ` string ` (optional)
93+ - ** fromId** : ` string ` (optional)
5494
5595 The handle of the start vertex of this edge. This can be either the ` _id ` of a
5696 document in the database, the ` _key ` of an edge in the collection, or a
5797 document (i.e. an object with an ` _id ` or ` _key ` property).
5898
59- * ** toId** : ` string ` (optional)
99+ - ** toId** : ` string ` (optional)
60100
61101 The handle of the end vertex of this edge. This can be either the ` _id ` of a
62102 document in the database, the ` _key ` of an edge in the collection, or a
63103 document (i.e. an object with an ` _id ` or ` _key ` property).
64104
65- * ** opts** : ` Object ` (optional)
105+ - ** opts** : ` Object ` (optional)
66106
67107 If _ opts_ is set, it must be an object with any of the following properties:
68108
69- * ** waitForSync** : ` boolean ` (Default: ` false ` )
109+ - ** waitForSync** : ` boolean ` (Default: ` false ` )
70110
71111 Wait until document has been synced to disk.
72112
73- * ** returnNew** : ` boolean ` (Default: ` false ` )
113+ - ** returnNew** : ` boolean ` (Default: ` false ` )
74114
75115 If set to ` true ` , return additionally the complete new documents under the
76116 attribute ` new ` in the result.
77117
78- * ** returnOld** : ` boolean ` (Default: ` false ` )
118+ - ** returnOld** : ` boolean ` (Default: ` false ` )
79119
80120 If set to ` true ` , return additionally the complete old documents under the
81121 attribute ` old ` in the result.
82122
83- * ** silent** : ` boolean ` (Default: ` false ` )
123+ - ** silent** : ` boolean ` (Default: ` false ` )
84124
85125 If set to true, an empty object will be returned as response. No meta-data
86126 will be returned for the created document. This option can be used to save
87127 some network traffic.
88128
89- * ** overwrite** : ` boolean ` (Default: ` false ` )
129+ - ** overwrite** : ` boolean ` (Default: ` false ` )
90130
91131 If set to true, the insert becomes a replace-insert. If a document with the
92- same _ key already exists the new document is not rejected with unique
132+ same \ _ key already exists the new document is not rejected with unique
93133 constraint violated but will replace the old document.
94134
95135If a boolean is passed instead of an options object, it will be interpreted as
@@ -133,7 +173,7 @@ Retrieves a list of all edges of the document with the given _documentHandle_.
133173
134174** Arguments**
135175
136- * ** documentHandle** : ` string `
176+ - ** documentHandle** : ` string `
137177
138178 The handle of the document to retrieve the edges of. This can be either the
139179 ` _id ` of a document in the database, the ` _key ` of an edge in the collection,
@@ -164,7 +204,7 @@ _documentHandle_.
164204
165205** Arguments**
166206
167- * ** documentHandle** : ` string `
207+ - ** documentHandle** : ` string `
168208
169209 The handle of the document to retrieve the edges of. This can be either the
170210 ` _id ` of a document in the database, the ` _key ` of an edge in the collection,
@@ -195,7 +235,7 @@ _documentHandle_.
195235
196236** Arguments**
197237
198- * ** documentHandle** : ` string `
238+ - ** documentHandle** : ` string `
199239
200240 The handle of the document to retrieve the edges of. This can be either the
201241 ` _id ` of a document in the database, the ` _key ` of an edge in the collection,
@@ -226,13 +266,13 @@ contained in this edge collection.
226266
227267** Arguments**
228268
229- * ** startVertex** : ` string `
269+ - ** startVertex** : ` string `
230270
231271 The handle of the start vertex. This can be either the ` _id ` of a document in
232272 the database, the ` _key ` of an edge in the collection, or a document (i.e. an
233273 object with an ` _id ` or ` _key ` property).
234274
235- * ** opts** : ` Object `
275+ - ** opts** : ` Object `
236276
237277 See
238278 [ the HTTP API documentation] ( https://docs.arangodb.com/latest/HTTP/Traversal/index.html )
0 commit comments