代码之家  ›  专栏  ›  技术社区  ›  Pablo Fernandez

如何使用连接查询Om Next中的所有数据?

  •  1
  • Pablo Fernandez  · 技术社区  · 10 年前

    在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-usage 来自 performance 记录:

    {: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->树来运行查询。

    2 回复  |  直到 10 年前
        1
  •  1
  •   Pablo Fernandez    10 年前

    这就是你的做法:

    [{: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]}}}
    
        2
  •  0
  •   egracer    10 年前

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

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

    {: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]}]}] 当然应该做到这一点。