Search code examples
neo4jgremlingraph-databasestruncate

Gremlin remove all Vertex


I know how to remove a vertex by id in Gremlin. But now I'm need to cleanup the database. How do I delete multiple vertices?

Deleting 1 v is like this:

    ver = g.v(1)
    g.removeVertex(ver)

I mean something like SQL TRUNCATE. How do you remove the vertices / vertexes without removing the class?


Solution

  • you can try

    g.V.each{g.removeVertex(it)}
    g.commit()