This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-28
Channels
- # announcements (5)
- # babashka (7)
- # beginners (101)
- # biff (9)
- # calva (46)
- # cider (6)
- # clj-yaml (2)
- # cljsrn (13)
- # clojure (11)
- # clojure-europe (43)
- # clojure-nl (13)
- # clojure-norway (22)
- # clojurescript (20)
- # conjure (1)
- # cursive (7)
- # data-science (2)
- # datomic (26)
- # emacs (38)
- # graphql (27)
- # gratitude (5)
- # hoplon (8)
- # hugsql (22)
- # humbleui (2)
- # hyperfiddle (6)
- # introduce-yourself (8)
- # joyride (3)
- # lsp (79)
- # malli (6)
- # nbb (67)
- # portal (16)
- # rdf (27)
- # reagent (42)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (36)
- # test-check (17)
- # tools-deps (1)
- # xtdb (15)
@djblue hi! Portal does not support Navigable, does it? I tried this
(tap> (->> (next.jdbc/execute! ds ["select * from book"])
(map #(update % :book/author (fn [v] ^{clojure.core.protocols/nav
(fn [books key id] (next.jdbc/execute-one! ds ["select * from person where _id=?" id]))}
[v])))))
and expected that when I click on the vectorized :book/author id, I will see the whole person map but it is just the ["some-id-123"]
vector with metadata.there is support for nav, click on the entry, press v
to show the possible views, I don't remember the name but you should see something related to nav there
It works for me with next.jdbc
-- pressing enter used to nav
it but maybe it got broken in a recent release?
Well it is the collection that is navigable. I had to wrap the item itself in it so that I could assign the necessary Metadata, since the value is string and cannot have them. I will try Enter and v as suggested when back in pc
You should be able to provide the nav fn via the parent map to avoid wrapping the id in a vector.
Ah, I thought it must be on the thing itself. That makes sense, will try. Thx!
Ok here is what I tried now and does not work (replacing jdbc with a db
map):
(let [db {:book [#:book{:id 1, :title "1984" :author 10}]
:person [#:person{:id 10 :fname "George" :lname "Orwell"}]}]
(tap> (->> (get db :book)
(map #(with-meta % {clojure.core.protocols/nav
(fn [_coll key value]
(if (= key :book/author)
(first (filter (comp #{value} :person/id) (:person db)))
value))})))))
In portal when I select the thing I want to be navigable - the author id - and press Enter, I just still see the number. Pressing v
shows diff viewers but no nav
viewer.@U0522TWDA You could just tell next.jdbc
about the :schema
where :book/author
is an FK to :person/_id
...
See https://cljdoc.org/d/seancorfield/next.jdbc/1.2.659/doc/datafy-nav-and-schema for how to specify that.
Awesome, thanks!