Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example of using nested select steps to select derived keys from an injected map #184

Open
krlawrence opened this issue Jun 2, 2020 · 0 comments

Comments

@krlawrence
Copy link
Owner

krlawrence commented Jun 2, 2020

gremlin> temps = [Atlanta:66.2,Austin:70.9,Anchorage:42.6,Seattle:54.1]
==>Atlanta=66.2
==>Austin=70.9
==>Anchorage=42.6
==>Seattle=54.1

gremlin> g.withSideEffect('t',temps).V().
......1>   has('city',within('Austin','Atlanta','Anchorage','Seattle')).
......2>   values('city').as('c').
......3>   project('Location','2019-Avg-Temp').
......4>     by().
......5>     by(select('t').select(select('c')))  

==>[Location:Atlanta,2019-Avg-Temp:66.2]
==>[Location:Anchorage,2019-Avg-Temp:42.6]
==>[Location:Austin,2019-Avg-Temp:70.9]
==>[Location:Seattle,2019-Avg-Temp:54.1]

This discussion probably would fit well right after section 3.23 where the inject() step is introduced.

Could further show that inject can be used with an as step to achieve the same result:

g.inject([Atlanta:66.2,Austin:70.9,Anchorage:42.6,Seattle:54.1]).as('t').
  V().
  has('city',within('Austin','Atlanta','Anchorage','Seattle')).
  values('city').as('c').
  project('Location','2019-Avg-Temp').
    by().
    by(select('t').select(select('c')))  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant