How insert data and how to use previous data?

Hi, im new on dgraph.

In one time, I try to insert two nodes with a relation. Next In another time, I want use one existing node to create a relation or add properties, but i want to use the existing node, like the MATCH on cypher.

{
  set {
   _:dg <name> "Dgraph" .

   _:me <name> "juanbits" .
   _:me <use> _:dg .
  }
}

and now i want use the previous “juanbits” node to create a new relationship, but it creates a new node

{
  set {
   _:dg <name> "Neo4j" .

   _:me <name> "juanbits" .
   _:me <use> _:dg .
  }
}
  • (at this point i have two “juanbits” nodes)

how can i check/use the existing “juanbits” node to add the relation with a new node or use existing node to add the relation with another node

First in your application you query for the user:

{
some(func: eq(name, "juanbits") ) {
   uid
  }
}

get it’s UID and then create your mutation:

{ 
 set { 
   _:dg <name> "Neo4j" . 
   <${MY_UID}> <use> _:dg . 
   } 
}

also you can check for https://docs.dgraph.io/howto/#upserts