1

Here is the code for adding Tribe Vertex

            let addTribe = g.addV('tribe')
            addTribe.property('tname', addTribeInput.tribename)
            addTribe.property('tribeadmin', addTribeInput.tribeadmin)

            const newTribe = await addTribe.next()

and Here is the code for adding Edges

             const addMember =  await 
                       g.V(addTribeInput.tribeadmin).addE('member').
                       to(g.V(newTribe.value.id)).next()

Is this is a correct way of adding edges?

I am just confusing what should I need to pass in .to() methoud

1 Answers1

0

Gremlin is meant to be chained, so unless you have an explicit reason to break things up, it's much nicer to just do:

g.addV('tribe').
    property('tname', addTribeInput.tribename).
    property('tribeadmin', addTribeInput.tribeadmin).as('x').
  V(newTribe.value.id).as('y').
  addE('member').
    from('x').
    to('y')

Given your variable names I'm not completely sure that I'm doing what you want exactly (e.g. getting the edge direction right), but the point here is that for adding edges you just need to specify the direction of the edge "from" one vertex (i.e. the starting vertex) "to" another vertex (i.e. the ending vertex).

stephen mallette
  • 45,298
  • 5
  • 67
  • 135