Hello,
I use spring data neo4j and i have the code like :
public class VmEntity {
@Id
@GeneratedValue
Long id;
String name;
@Labels
List<String> nodeLabels;
@Relationship(type = "CONTAINS", direction = Relationship.INCOMING)
private List<ClusterEntity> clusters = new ArrayList<>();
}
and repository like :
public interface VmRepository extends Neo4jRepository<VmEntity, Long> {
Optional<VmEntity> findByName(String name);
@Query("MATCH (n {name:$name}) " +
"WHERE 'VM' IN labels(n) " +
"REMOVE n:Alert " +
"RETURN n")
VmEntity removeAlertLabel(String name);
@Query("MATCH (n) " +
"RETURN n")
Result getTheGraph();
@QueryResult
public class Result{
List<Node> nodes;
List<Link> links;
}
I want to know how can i return all the graph like "MATCH (n) RETURN n " and transform result to an object :
{
nodes: [{id: 1, name: "N1"}, {id: 2, name: "N2"}],
links : [{source: "N1", target: "N2"}]
}
Thank you