mirror of https://gitee.com/bigwinds/arangodb
Graph: Replace a given vertex by ID
This commit is contained in:
parent
3da8d973f9
commit
04c7cfce33
|
@ -279,6 +279,14 @@ Graph.prototype._saveVertex = function (id, params) {
|
|||
return new Vertex(this, results.vertex);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief replace a vertex in the graph
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype._replaceVertex = function (id, data) {
|
||||
GraphAPI.putVertex(this._properties._key, id, data);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns a vertex given its id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -781,6 +781,18 @@ Graph.prototype.addVertex = function (id, data, waitForSync) {
|
|||
return this._saveVertex(id, this._prepareVertexData(data), waitForSync);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief replaces an existing vertex by ID
|
||||
///
|
||||
/// @FUN{@FA{graph}.replaceVertex(@FA{id}, @FA{data})}
|
||||
///
|
||||
/// Replaces an existing vertex by ID
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.replaceVertex = function (id, data) {
|
||||
this._replaceVertex(id, data);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the number of vertices
|
||||
///
|
||||
|
|
|
@ -194,6 +194,18 @@ function GraphBasicsSuite() {
|
|||
assertEqual(23, v2.getProperty("age"));
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief replace a vertex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testReplaceVertex : function () {
|
||||
var v = graph.addVertex("vertex_to_replace", { age : 23 });
|
||||
graph.replaceVertex("vertex_to_replace", { age: 24 });
|
||||
v = graph.getVertex("vertex_to_replace");
|
||||
|
||||
assertEqual(24, v.getProperty("age"));
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief change a property
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue