This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-03
Channels
- # ai (1)
- # announcements (1)
- # beginners (5)
- # biff (23)
- # clojure (3)
- # clojure-europe (4)
- # clojure-norway (22)
- # clojurescript (21)
- # data-science (1)
- # datascript (5)
- # graalvm (2)
- # gratitude (2)
- # humbleui (4)
- # hyperfiddle (10)
- # lsp (46)
- # off-topic (15)
- # pedestal (1)
- # reitit (3)
- # shadow-cljs (12)
- # sql (4)
Hi! I have a datascript query that returns a sequence of vectors of maps. All the vectors are of length 1. Is there a way to write the datascript query to return a sequence of maps instead?
(->>
(d/q '[:find (pull ?e [:slug :title])
:where
[?e :page/slug ?slug]
[?e :title ?title]
[?e :form :remote-reference]]
db)
shuffle
(take 3))
;; =>
;; ([{:slug "roam-research", :title "Roam Research"}]
;; [{:slug "j-programming-language", :title "J (programming language)"}]
;; [{:slug "eliyahu-goldratt", :title "Eliyahu Goldratt"}])
✅ 1
That did the trick. Thank you! I tried reading the Datomic docs, but I didn’t find the right section.
(->>
(d/q '[:find [(pull ?e [:slug :title]) ...]
:where
[?e :form :remote-reference]]
db)
shuffle
(take 3))
;; => ({:slug "emacs-lisp", :title "Emacs Lisp"}
;; {:slug "antifragile", :title "Antifragile"}
;; {:slug "dtype-next", :title "dtype-next"})