Skip to content

Instantly share code, notes, and snippets.

@jlongster
Created January 28, 2016 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlongster/acd2ab1c00b52673972e to your computer and use it in GitHub Desktop.
Save jlongster/acd2ab1c00b52673972e to your computer and use it in GitHub Desktop.
(def my-state
{:transactions {:list/transactions
[[:transaction/by-id 1] [:transaction/by-id 2] [:transaction/by-id 3] [:transaction/by-id 4]]},
:transaction/by-id {1 {:from_acct [{:balance 0, :id 4, :name "income"}], :id 1, :to_acct [{:balance 0, :id 1, :name "bank of america"}], :amount 3.5, :date 1453243176928},
2 {:from_acct [{:balance 0, :id 4, :name "income"}], :id 2, :to_acct [{:balance 0, :id 2, :name "chase"}], :amount 7, :date 1453243176928},
3 {:from_acct [{:balance 0, :id 4, :name "income"}], :id 3, :to_acct [{:balance 0, :id 3, :name "credit"}], :amount 12.1, :date 1453243176928},
4 {:from_acct [{:balance 0, :id 4, :name "income"}], :id 4, :to_acct [{:balance 0, :id 1, :name "bank of america"}], :amount 9.44, :date 1453243176928}},
:om.next/tables #{:transaction/by-id}})
(om/db->tree '[{:transactions [{:list/transactions [:amount]}]}] my-state my-state)
;; -> {:transactions {:list/transactions [{:amount 3.5} {:amount 7} {:amount 12.1} {:amount 9.44}]}}
(om/db->tree '[{:transactions [{:list/transactions [*]}]}] my-state my-state)
;; -> {:transactions {:list/transactions [{} {} {} {}]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment