SELECT OBJECT d.[TO_STR(v1.id)]:v1 FOR v1 IN av END AS chart
FROM default AS d USE KEYS "chart_a"
LET av = (SELECT RAW d2 FROM default AS d2 USE KEYS (ARRAY "a:a2t" || v FOR v IN OBJECT_NAMES(d) END));
The problem I have is that the key of the resulting object should be the value of the initial object (chart_a).
And I just can’t mkae it work no matter what I do :((
where the keys 1,2,etc are the values of the initial document.
So, I need to get the values of the object from the initial document, transform in keys and then add the result from another documents as values to these keys
INSERT INTO default VALUES ("ch01", { "country_code": "ae", "chart_timestamp": 1597536000, "chart_a": { "1000008721": 5, "403274099": 2, "432756187": 1, "454403780": 3, "463569251": 4, "493073807": 7, "493837285": 6, "501344243": 8 }, "version": 1 });
INSERT INTO default VALUES ("a:a2t:432756187", { "id": 432756187, "uuid": "8067ae4f-59d9-497c-adf0-d87b8ecb654f" });
INSERT INTO default VALUES ("a:a2t:403274099", { "id": 403274099, "uuid": "4a20c2a9-8e36-4b7d-b961-e403d4a3cf5f" });
SELECT OBJECT TO_STR(d.chart_a.[TO_STR(v1.id)]):v1
FOR v1 IN (SELECT RAW d2 FROM default AS d2 USE KEYS (ARRAY "a:a2t:" || v FOR v IN OBJECT_NAMES(d.chart_a) END))
END AS chart
FROM default AS d
WHERE d.country_code = "ae";