I have been trying to figure this if-else in a Gremlin query. Assume g.V({0}) is the group vertex below.
var q = "g.V({0}).as('groupName', 'groupId', 'ownerId').inE(eIsAdminOf, eIsMemberOf).as('rel', 'joinDate').outV().hasLabel(userLabel).as('memberId')";
//TODO:var q = "g.V({0}).as('groupName', 'groupId', 'ownerId').inE(eIsAdminOf";
//if .has('mCanList',true).inE(eIsAdminOf, eIsMemberOf)
//if .has('mCanList',false).inE(eIsAdminOf)
//, eIsMemberOf).as('rel', 'joinDate').outV().hasLabel(userLabel).as('memberId')";
I want the .inE(eIsAdminOf, eIsMemberOf)
to be based on property value mCanList of true or false as in the comments above.
Have been trying a choose to no avail:
var q = "g.V({0}).as('groupName', 'groupId', 'ownerId','mCanList');
q += ".by(values('mCanList').choose(is(true),.inE(eIsAdminOf, eIsMemberOf), .inE(eIsAdminOf))";
q += '.as('rel', 'joinDate').outV().hasLabel(userLabel).as('memberId')”;
I am using node.js to build the gremlin query with the gremlin library. The worst option for me is to build 2 separate async queries which build the results separately based on
if .has('mCanList',true).inE(eIsAdminOf, eIsMemberOf) or
if .has('mCanList',false).inE(eIsAdminOf)
TIA