Advertisement
Guest User

Om Nex Foreign Keys

a guest
Aug 29th, 2017
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {:users
  2.  [[:user/by-id 1] [:user/by-id 3] [:user/by-id 4] [:user/by-id 6]],
  3.  :roles [[:role/by-id 1]],
  4.  :user/by-id
  5.  {1
  6.   {:id 1,
  7.    :email "foo@example.com",
  8.    :role 1},
  9.   3
  10.   {:id 3,
  11.    :email "bar@floyhamilton.nl",
  12.    :role 1},
  13.   4
  14.   {:id 4,
  15.    :email "baz@example.com",
  16.    :role 1},
  17.   6
  18.   {:id 6,
  19.    :email "nom@example.com",
  20.    :role 1}},
  21.  :role/by-id {1 {:id 1, :name "admin"}}}
  22.  
  23. (defui Role
  24.   static om/Ident
  25.   (ident [this {:keys [id]}]
  26.          [:role/by-id id])
  27.   static om/IQuery
  28.   (query [this]
  29.          [:id :name]))
  30.  
  31. (defui User
  32.   static om/Ident
  33.   (ident [this {:keys [id]}]
  34.          [:user/by-id id])
  35.   static om/IQuery
  36.   (query [this]
  37.          '[:id :email :role [:role/by-id ~role]]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement