Skip to content

access parent field in for expression #163

Answered by larsga
agent-mo asked this question in Q&A
Discussion options

You must be logged in to vote

The thing here is that if we allow accessing the parent it becomes very difficult to reuse nodes from the input in the output, which means we have to do costly copying. There is a simple workaround: you can capture the user id in a variable before you start the loop:

let user_id = (.user_id)
[ for (.friends) { "user_id": $user_id , "friend_id" : .friend_id } ]

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@agent-mo
Comment options

Answer selected by larsga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants