This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-01
Channels
- # aleph (3)
- # announcements (10)
- # babashka (6)
- # bangalore-clj (4)
- # beginners (91)
- # biff (7)
- # cider (25)
- # cljs-dev (1)
- # clojure (109)
- # clojure-europe (9)
- # clojure-norway (5)
- # clojure-uk (1)
- # clojurescript (22)
- # cursive (22)
- # data-science (1)
- # datalevin (5)
- # datomic (7)
- # emacs (7)
- # etaoin (1)
- # events (3)
- # graphql (12)
- # hyperfiddle (1)
- # inf-clojure (1)
- # lsp (69)
- # luminus (1)
- # meander (21)
- # nbb (4)
- # off-topic (27)
- # other-languages (12)
- # rdf (58)
- # releases (3)
- # remote-jobs (2)
- # rum (12)
- # shadow-cljs (4)
- # sql (3)
- # xtdb (1)
Hi guys, I need to retrieve id's from all users in database that are older then 30 days, every user has creation date.,
(let [conn (client/get-conn)
db (client/db)
last-month (t/minus (t/now) (t/month 1))
q '{:find [(pull ?eid [*])]
:where [[?eid :user/created]]}]
;;.............
)
I have last-month #inst date, I just dont know how to get all users "older" then 30 days.
I am new in datomic so,
if someone can help, thank you in advance...(let [conn (client/get-conn)
db (client/db)
;; using java.time
#_#_last-month (Date/from (.minus (Instant/now)
(Duration/ofDays 30)))
last-month (t/minus (t/now) (t/month 1))]
;; get the created from the instant where user/id was created
#_(d/q '{:find [(pull ?eid [*])]
:in [$ ?last-month]
:where [[?eid :user/id _ ?tx]
[?tx :db/txInstant ?created]
[< ?created ?last-month]]}
db last-month)
(d/q '{:find [(pull ?eid [*])]
:in [$ ?last-month]
:where [[?eid :user/created ?created]
[< ?created ?last-month]]}
db last-month))
Thank you
IDK what t/minus
returns, but d/q
requires something that look like a java.util.Date
it returns a instance like this #<DateTime 1986-10-14T04:00:00.000Z>
i am saving creation date as Date instance so this solution works best right now, if i didnt have this solution i would need to change how create time is written in database, and to replace (new Date) with (t/now)
last-month (t/minus (t/now) (t/month 1))
this is from clj-time library