diff --git a/html/admin/js/bootstrap/module-internal.js b/html/admin/js/bootstrap/module-internal.js
index ad7b711fb2..bf55b6e116 100644
--- a/html/admin/js/bootstrap/module-internal.js
+++ b/html/admin/js/bootstrap/module-internal.js
@@ -1,7 +1,8 @@
-/*jslint indent: 2, nomen: true, maxlen: 120, vars: true, white: true, plusplus: true, nonpropdel: true, proto: true, regexp: true */
-/*global require, module, Module, ArangoError, SYS_DEBUG_SET_FAILAT, SYS_DEBUG_REMOVE_FAILAT,
- SYS_DEBUG_CLEAR_FAILAT, SYS_DOWNLOAD,
- SYS_EXECUTE, SYS_LOAD, SYS_LOG_LEVEL, SYS_MD5, SYS_OUTPUT, SYS_PROCESS_STATISTICS,
+/*jslint indent: 2, nomen: true, maxlen: 120, vars: true, white: true, plusplus: true, nonpropdel: true, proto: true */
+/*jslint sloppy: true, regexp: true */
+/*global require, module, Module, ArangoError,
+ SYS_DEBUG_CAN_USE_FAILAT, SYS_DEBUG_SET_FAILAT, SYS_DEBUG_REMOVE_FAILAT, SYS_DEBUG_CLEAR_FAILAT,
+ SYS_DOWNLOAD, SYS_EXECUTE, SYS_LOAD, SYS_LOG_LEVEL, SYS_MD5, SYS_OUTPUT, SYS_PROCESS_STATISTICS,
SYS_RAND, SYS_SERVER_STATISTICS, SYS_SPRINTF, SYS_TIME, SYS_START_PAGER, SYS_STOP_PAGER,
SYS_SHA256, SYS_WAIT, SYS_PARSE, SYS_IMPORT_CSV_FILE, SYS_IMPORT_JSON_FILE, SYS_LOG,
SYS_GEN_RANDOM_NUMBERS, SYS_GEN_RANDOM_ALPHA_NUMBERS, SYS_GEN_RANDOM_SALT, SYS_CREATE_NONCE,
@@ -74,7 +75,7 @@
}
this.message = this.toString();
- }
+ };
exports.ArangoError.prototype = Error.prototype;
}
diff --git a/html/admin/js/modules/org/arangodb/graph-common.js b/html/admin/js/modules/org/arangodb/graph-common.js
index cfe09e38c6..d534614aa3 100644
--- a/html/admin/js/modules/org/arangodb/graph-common.js
+++ b/html/admin/js/modules/org/arangodb/graph-common.js
@@ -30,6 +30,7 @@ module.define("org/arangodb/graph-common", function(exports, module) {
////////////////////////////////////////////////////////////////////////////////
var arangodb = require("org/arangodb"),
+ is = require("org/arangodb/is"),
Edge,
Graph,
Vertex,
@@ -569,6 +570,59 @@ Graph.prototype.getOrAddVertex = function (id) {
return v;
};
+////////////////////////////////////////////////////////////////////////////////
+/// @brief adds an edge to the graph
+///
+/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in}, @FA{id})}
+///
+/// Creates a new edge from @FA{out} to @FA{in} and returns the edge object. The
+/// identifier @FA{id} must be a unique identifier or null.
+///
+/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in}, @FA{id}, @FA{label})}
+///
+/// Creates a new edge from @FA{out} to @FA{in} with @FA{label} and returns the
+/// edge object.
+///
+/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in}, @FA{id}, @FA{data})}
+///
+/// Creates a new edge and returns the edge object. The edge contains the
+/// properties defined in @FA{data}.
+///
+/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in}, @FA{id}, @FA{label}, @FA{data})}
+///
+/// Creates a new edge and returns the edge object. The edge has the
+/// label @FA{label} and contains the properties defined in @FA{data}.
+///
+/// @EXAMPLES
+///
+/// @verbinclude graph-graph-add-edge
+///
+/// @verbinclude graph-graph-add-edge2
+////////////////////////////////////////////////////////////////////////////////
+
+Graph.prototype.addEdge = function (out_vertex, in_vertex, id, label, data, waitForSync) {
+ var params;
+
+ if (is.notExisty(data) && typeof label === 'object') {
+ data = label;
+ label = null;
+ }
+
+ if (is.notExisty(label) && is.existy(data) && is.existy(data.$label)) {
+ label = data.$label;
+ }
+
+ if (data === null || typeof data !== "object") {
+ params = {};
+ } else {
+ params = data._shallowCopy || {};
+ }
+
+ params.$label = label;
+
+ return this._saveEdge(id, out_vertex, in_vertex, params, waitForSync);
+};
+
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
diff --git a/html/admin/js/modules/org/arangodb/graph.js b/html/admin/js/modules/org/arangodb/graph.js
index b19c85ce20..f65d5de210 100644
--- a/html/admin/js/modules/org/arangodb/graph.js
+++ b/html/admin/js/modules/org/arangodb/graph.js
@@ -425,25 +425,10 @@ Graph.prototype.drop = function () {
/// @brief adds an edge to the graph
////////////////////////////////////////////////////////////////////////////////
-Graph.prototype.addEdge = function (out_vertex, in_vertex, id, label, data) {
- var requestResult;
- var params;
- var key;
-
- if (data === null || typeof data !== "object") {
- params = {};
- } else {
- params = data._shallowCopy || {};
- }
-
+Graph.prototype._saveEdge = function(id, out_vertex, in_vertex, params) {
params._key = id;
params._from = out_vertex._properties._key;
params._to = in_vertex._properties._key;
- params.$label = label;
-
- if (is.notExisty(params.$label) && is.existy(data) && is.existy(data.$label)) {
- params.$label = data.$label;
- }
requestResult = this._connection.POST("/_api/graph/"
+ encodeURIComponent(this._properties._key) + "/edge",
diff --git a/js/client/modules/org/arangodb/graph.js b/js/client/modules/org/arangodb/graph.js
index 9652ed2b1f..aa26a5979a 100644
--- a/js/client/modules/org/arangodb/graph.js
+++ b/js/client/modules/org/arangodb/graph.js
@@ -429,7 +429,7 @@ Graph.prototype._saveEdge = function(id, out_vertex, in_vertex, params) {
params._from = out_vertex._properties._key;
params._to = in_vertex._properties._key;
- requestResult = this._connection.POST("/_api/graph/"
+ var requestResult = this._connection.POST("/_api/graph/"
+ encodeURIComponent(this._properties._key) + "/edge",
JSON.stringify(params));
diff --git a/js/server/modules/org/arangodb/graph.js b/js/server/modules/org/arangodb/graph.js
index cd13cedcaa..21d66f7110 100644
--- a/js/server/modules/org/arangodb/graph.js
+++ b/js/server/modules/org/arangodb/graph.js
@@ -648,8 +648,8 @@ Graph.prototype._saveEdge = function(id, out_vertex, in_vertex, shallow, waitFor
shallow._key = String(id);
}
- ref = this._edges.save(out_vertex._properties._id,
- in_vertex._properties._id, shallow, waitForSync);
+ var ref = this._edges.save(out_vertex._properties._id,
+ in_vertex._properties._id, shallow, waitForSync);
return this.constructEdge(ref._id);
};