Fork me on GitHub
#datomic
<
2016-03-07
>
isaac04:03:22

there is two problem confuse me about Datomic: 1. Should I prefer enumerated value than keyword. db.type/ref OR db.type/keyword 2. I have an entity (a user) which created old thant t. Is this user will recycle when I call (gc-storage conn t) if this user never updated after created?

isaac04:03:42

@bkamphaus: there is no reply

bkamphaus04:03:25

@isaac: there definitely is one, but Google Groups always had bad delays for update/refresh - it may take a couple of minutes to show up in your view. File under “eventually consistent” I guess.

isaac04:03:04

@bkamphaus: I seen your reply. thanks

wei04:03:04

I’m trying to parameterize the arguments to a find specification

wei04:03:06

(defn sample-n [db n]
  (d/q '[:find (sample ?n ?a) .
         :in $ ?n
         :where [?a :account/uuid]]
       db n))

wei04:03:22

but I’m getting an Exception: clojure.lang.Symbol cannot be cast to java.lang.Number

wei04:03:44

what’s the right way to pass in n?

hiredman05:03:59

you could stick the number in the quoted form, which is how I've seen it done in the examples

hiredman05:03:25

`[:find (sample ~n ?a) ...]

hiredman05:03:05

but my experience with datomic is limited, so I am not sure if you'll run in to issues using syntax-quote there

wei05:03:50

like this?

(defn sample-n [db n]
  (d/q `[:find (sample ~n ?a) .
         :in $
         :where [?a :account/uuid]]
       db))

hiredman05:03:18

are you sure you want the find scalar dot?

wei05:03:19

That results in :db.error/invalid-data-source Nil or missing data source. Did you forget to pass a database argument? when called

hiredman05:03:32

I don't think that makes sense with sample

wei05:03:44

which is surprising for me

wei05:03:15

without the dot it returns the sample with another layer of nesting

hiredman05:03:54

oh, no kidding

hiredman05:03:50

you could try building the expression using regular quote, in case the namespace qualifying that syntax quote does is screwing it up

hiredman05:03:48

[:find (list 'sample n '?a) '. :in '$ :where ['?a :account/uuid]]

wei05:03:14

interesting thing is, this seems to work in pull expressions:

wei05:03:15

(defn all-products [db]
  (d/q '[:find [(pull ?e product-props) ...]
         :in $ product-props
         :where [?e :product/slug]]
       db product-props))

wei05:03:34

not sure what’s different about the two

hiredman05:03:11

you used ?n for the other one

marshall14:03:55

@wei: This might be what you’re shooting for:

(defn sample-query [x]
  (let [my-sample (list 'sample x '?m)]
    {:find [my-sample]
     :in '[$]
     :where '[[?m :track/name]]}))


(d/q (sample-query 3) db)