1

在 Om Next 中,当有以下数据时:

{:table      {:name "Disk Performance Table"
              :data [:statistics :performance]}
 :chart      {:name "Combined Graph"
              :data [:statistics :performance]}
 :statistics {:performance {:cpu-usage        [45 15 32 11 66 44]
                            :disk-activity    [11 34 66 12 99 100]
                            :network-activity [55 87 20 1 22 82]}}}

您可以通过以下方式查询它:

[{:chart [{:data [:cpu-usage]}]}]

要获取图表,请加入并从记录中data挖掘:cpu-usageperformance

{:chart {:data {:cpu-usage [45 15 32 11 66 44]}}}

我如何获得整个性能记录?

另一个潜在的查询是:

[{:chart [:data]}]

但它不能解决联接:

{:chart {:data [:statistics :performance]}}

没有组件,因为这仅与数据和查询有关。这是来自练习号 2 和此处的查询:https ://awkay.github.io/om-tutorial/#! /om_tutorial.D_Queries 它使用 om/db->tree 来运行查询。

4

2 回答 2

1

这就是你的做法:

[{:chart [{:data [*]}]}]

这给了你:

{:chart {:data {:cpu-usage        [45 15 32 11 66 44]
                :disk-activity    [11 34 66 12 99 100]
                :network-activity [55 87 20 1 22 82]}}}
于 2016-01-23T17:37:02.620 回答
0

如果没有看到带有查询和标识的实际组件,我无法确定。

但是,您应该能够查询[{:chart [:data]}]. 见om/db->tree。假设您已经使用正确的查询和标识构建了组件,om/db->tree请将您的平面应用程序状态转换为树,以便您的读取函数在调用时看到以下数据:

{:table      {:name "Disk Performance Table"
              :data {:cpu-usage        [45 15 32 11 66 44]
                     :disk-activity    [11 34 66 12 99 100]
                     :network-activity [55 87 20 1 22 82]}}
 :chart      {:name "Combined Graph"
              :data {:cpu-usage        [45 15 32 11 66 44]
                     :disk-activity    [11 34 66 12 99 100]
                     :network-activity [55 87 20 1 22 82]}}}

如果该查询不起作用,[{:chart [{:data [:cpu-usage :disk-activity :network-activity]}]}]当然应该解决问题。

于 2016-01-21T05:03:38.553 回答