给定一个发出散列数组的管道。每个 indicators 键具有数组的值:
indicators
[{ "indicators" => [ "SMA:1", "SMA:2", "SMA:3" ]}, ...
如何使用管道转换 indicators 要获取的哈希值的数组:
[{ "indicators" => { "SMA:1" => true, "SMA:2" => true, "SMA:3" => true }}, ...
mi7gmzs61#
使用$map从中Map数组 ['v1', 'v2', 'v3'] 到 [['v1', true], ['v2', true], ['v3', true]] ,然后使用https://docs.mongodb.com/manual/reference/operator/aggregation/arraytoobject/ 将其转换为散列。
['v1', 'v2', 'v3']
[['v1', true], ['v2', true], ['v3', true]]
1条答案
按热度按时间mi7gmzs61#
使用$map从中Map数组
['v1', 'v2', 'v3']
到[['v1', true], ['v2', true], ['v3', true]]
,然后使用https://docs.mongodb.com/manual/reference/operator/aggregation/arraytoobject/ 将其转换为散列。