-
Notifications
You must be signed in to change notification settings - Fork 0
Array mapping resolver name
Tracy Li edited this page Jun 4, 2018
·
1 revision
Today we using $. for trigger mapping(means current scope) and array mapping(to get current context value)
It has an issue when doing an array mapping in trigger mapping, it doesn't know it from a trigger or current array context.
Upon we discussed on Friday(June 1), we will continue to use $. for trigger mapping but need to find another way for array mapping
Take an example doing an array mapping inside a rest trigger.
{
"mappings": {
"input": [
{
"mapTo": "flowInputLevel1",
"type": "array",
"value": {
"fields": [
{
"from": "$.id1",
"to": "$$['id1']",
"type": "primitive"
},
{
"fields": [
{
"from": "$.id2",
"to": "$$['id2']",
"type": "primitive"
},
{
"from": "$.name2",
"to": "$$['name2']",
"type": "primitive"
}
],
"from": "$.triggerOutputLevel2",
"to": "$$['flowInputLevel2']",
"type": "foreach"
},
{
"from": "$.name1",
"to": "$$['name1']",
"type": "primitive"
}
],
"from": "$.body.triggerOutputLevel1",
"to": "flowInputLevel1",
"type": "foreach"
}
},
{
"mapTo": "flowRootField",
"type": "expression",
"value": "$.body.rootField"
}
]
}
- Straight mapping trigger root field(
$.body.rootField) toflowRootField.$.bodymeans get currect tirgger attributebody. - Another mapping is an array mapping structure. Map trigger output
$.body.triggerOutputLevel1toflowInputLevel1, both are JSON array. foreachtrigger outputLevel1and assigin it'sid1andname1to flow flowInputLevel1 fieldid1andname1, same with second level.
For both 1 and 2 mapping are using $. the prefix which confuses. #1 using $. to get current data scope data but #2 using for current array context.
Several approaches.
- $element
- $current --> Today the iterator feature already token $current
- $array
- $iterator --> $Iterator more like foreach or loop, the resolver should just for currect loop context.
- more.....
Assume we have 2 level array, how to access first level data from second level? Some approaches
- $current["FlowinputLevel1"].id
- $current["arrayinputLevel1.arrayInputLevel2"].id