0

I have a set of data that looks like this:

Users

I can go a super simple g.V('group_id').in('user').valueMap() to retrieve all the users and their properties. I can also retrieve the roles, but somehow, I can't retrieve all at once.

What I need to get is something like this:

==>{u={user_id=[474531d1], name=[User 1], email=[a@acme.com]},r=[role A, role B, role C]}
==>{u={user_id=[474531d4], name=[User 2], email=[a@acme.com]},r=[role A, role B]}
==>{u={user_id=[474531da], name=[User 3], email=[a@acme.com]},r=[role C]}

I've tried with map, union, but either I get one set of things like users, or roles but never both.

E.T
  • 1,095
  • 1
  • 10
  • 19

1 Answers1

1

I would think all you need is something like

g.V('group-id').
  in('user').
  project('user','roles').
    by(valueMap()).
    by(out('role').valueMap().fold())
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
  • Genius! Thank you so much, exactly what I needed. Didn't really think of project() to be honest. Not sure why I was looking to complicate my life with maps and unions :) – E.T Aug 08 '21 at 18:40