Skip to content

Commit

Permalink
Utility function for flushing local db (#94)
Browse files Browse the repository at this point in the history
works only for gremlin version 3.x
  • Loading branch information
agroebe authored Sep 4, 2020
1 parent 158e0e7 commit a75a01e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion graphexp.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ <h1 class="header-heading">Graph Explorer v 0.6</h1>
<div class="nav input_unit_container", id="editGraph" style="display:none;">
<button onclick="addVertexForm()" style="height:25px; width:150px" > Add Vertex </button><br>
<button onclick="editVertexForm()" style="height:25px; width:150px" > Edit Vertex </button><br>
<button onclick="addEditEdgeForm()" style="height:25px; width:150px" > Add/Edit Edge </button><br>
<button onclick="addEditEdgeForm()" style="height:25px; width:150px" > Add/Edit Edge </button><br>
<button onclick="flush()" style="height:25px; width:150px" > Flush </button><br>
</div>

<div class="nav input_unit_container", id="addVertexForm" style="display:none;">
Expand Down
5 changes: 5 additions & 0 deletions scripts/editGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,10 @@
editGraph();
}
}

function flush() {
const gremlin_query = "g.V().drop().iterate()"
graphioGremlin.send_to_server(gremlin_query, 'flushGraph', null, "")
}


7 changes: 7 additions & 0 deletions scripts/graphioGremlin.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ var graphioGremlin = (function(){
}
var data = response.result.data;
if (data == null){
// No response data expected for flush query, so just validate status code.
if (query_type == 'flushGraph' && response.status.code == 204) {
$('#outputArea').html("<p> Successfully flushed existing DB data.</p>");
$('#messageArea').html('');
return
}

if (query_type == 'editGraph'){
$('#outputArea').html(response.status.message);
$('#messageArea').html('Could not write data to DB.' +
Expand Down

0 comments on commit a75a01e

Please sign in to comment.