1

In Om Next, when having data such as:

{: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]}}}

you can query it with:

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

to get the chart, join the data and dig down cpu-usage from the performance record:

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

How do I get the whole performance record instead?

Another potential query is this:

[{:chart [:data]}]

but it doesn't resolve the join:

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

There are no components as this is only about the data and the query. This is from the exercise number 2 and queries here: https://awkay.github.io/om-tutorial/#!/om_tutorial.D_Queries which uses om/db->tree to run the queries.

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

2 Answers2

1

This is how you do it:

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

which gives you:

{: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]}}}
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
0

Without seeing the actual components with queries and idents, I can't be sure.

However, you should be able to query for [{:chart [:data]}]. See om/db->tree. Assuming that you have structured your components with the right queries and idents, om/db->tree converts your flat app state into a tree so that your read functions see the following data when called:

{: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]}}}

If that query doesn't work, [{:chart [{:data [:cpu-usage :disk-activity :network-activity]}]}] should certainly do the trick.

egracer
  • 362
  • 3
  • 10
  • There are no components or idents, this is just that data. I linked to the exercise I'm working on. It is using om/db->tree. Just asking for :data doesn't resolve the join, so, it's not what I want; asking for each specific element is still not *getting them all*; only those specific elements. – Pablo Fernandez Jan 23 '16 at 15:36