1

I have used this query

g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').properties('startedOn','17/15/07','title','manager','pay',15000) 

which doesn't work.

Adding a single property works with a .property step

g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').property('startedOn','17/15/07') 
Bart
  • 19,692
  • 7
  • 68
  • 77
Rajgopal
  • 13
  • 1
  • 4

1 Answers1

3

Instead of specifying all properties in one property-step, you can simply concatenate multiple property-steps:

g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').
    property('startedOn','17/15/07').property('title','manager').property('pay',15000)

Your query doesn't specify which vertices should be connected by the edge. When you want the edge to go out from the vertex with the empId 123, then you have to insert a from:

g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').from('a').
    property('startedOn','17/15/07').property('title','manager').property('pay',15000)

See the addEdge-step for more information.

Florian Hockmann
  • 2,634
  • 13
  • 24
  • What if I have a Map or a List of properties? – foxtrotuniform6969 Dec 10 '22 at 21:57
  • 1
    @foxtrotuniform6969 you mean you have a map where you want to store each key/value pair as a property? Or do you want to store a map/list as one single property where the map/list should become the value of the property? In case of the former, this was already answered a few times, for example [here][https://stackoverflow.com/q/68935172/6753576] and [here][https://stackoverflow.com/q/60602990/6753576]. – Florian Hockmann Dec 12 '22 at 07:44
  • The latter, and thank you. – foxtrotuniform6969 Dec 12 '22 at 11:59
  • Then it depends on your graph database whether that supports maps or lists directly as property values or not. For Neptune for example, this was already asked here for lists: https://stackoverflow.com/q/52737958/6753576 If you have problems with that, then please create a new question. – Florian Hockmann Dec 13 '22 at 15:03