Add new values to .saveAs("var")

Hello there.

I have a websocket server which returns a JSON with some data if I subscribe on proper model with proper id.
I have a list of those ids and subscribe in the loop on model with each id.
Server returns JSON on every subscription.
I fetch via jsonPath another ids and save them.

Problem is that in next iteration previously saved ids would be overwritten by new ones.
Lets say:

With first run of the loop I’ll receive 10 “anotherids”
With second - five.
With the last - one.

So “anotherIds” in the end of the loops will contain only one id instead of all that was collected during the loop.
Is there a way to accumulate data in ‘saveAs’ variable with each loop iteration?

Example of code:

val subscription = exec(ws(“subscribe on model”)
.sendText("""[“subscribe_on_model”, {“collection”: “Model”, “id”: 2}]""")
.check(wsAwait.within(20).until(1).jsonPath("$…someIds[*]").findAll.saveAs(“someIds”)))

.foreach("${someIds}", “someId”) {
exec(ws(“subscribe on model2”)
.sendText("""[“subscribe_on_model”, {“collection”: “Model2”, “id”: “${someId}”}]""")
.check(wsAwait.within(20).until(1).jsonPath("$…anotherIds[*]").findAll.saveAs(“anotherIds”)))
}

.foreach("${anotherIds}", “anotherId”) {
exec(ws(“subscribe on model3”)
.sendText("""[“subscribe_on_model”, {“collection”: “Model3”, “id”: “${anotherId}”}]""")
.check(wsAwait.within(20).until(1).jsonPath("$…someAnotherIds[*]").findAll.saveAs(“someAnotherIds”)))
}

You might consider merging the three sequences (someIds, anotherIds, someAnotherIds) after the the last foreach. Not ideal, but…

Perhaps my explanation was quite vague.
The problem lays within one foreach. Since with each iteration for example “anotherIds” got overwritten.
I want to have all data that was saved during foreach in that var.

Ah, yeah, my bad. So, you’re looking for saveAs to function like an ‘appendTo’, if it existed. I believe you’re out of luck. Happy to be told otherwise.