I’m trying to set the teamId in history to the teamId of the parent game.
For this data layout…
{
docId: 'someId',
games: [
{
teamId: 'teamVal1',
history: [
{
teamId: 'teamVal2',
actionId: 'view'
},
{
teamId: 'teamVal2',
actionId: 'change'
},
{
teamId: 'teamVal2',
actionId: 'view'
}
]
},
{
teamId: 'teamVal3',
history: [
{
teamId: 'teamVal2',
actionId: 'view'
},
{
teamId: 'teamVal2',
actionId: 'build'
},
{
teamId: 'teamVal2',
actionId: 'view'
},
]
}
]
}
The following update statement does not work (probably because g goes out of scope), but it does convey what I’m trying to do…
UPDATE `bucket` AS dc
SET h.teamId = g.teamId
FOR h IN ARRAY_FLATTEN(ARRAY g.history FOR g IN dc.games END,1)
WHEN (h.`actionId` in ["view"])
END
Any ideas?
thanks