Fork me on GitHub
#datomic
<
2017-01-04
>
zmaril17:01:45

@uwo datascript can do that

uwo17:01:23

@zmaril thanks. I’ve used datascript before and enjoyed it very much. However, I was thinking of working with data structures that are not indexed or stored in a ref.

uwo17:01:10

I’m also familiar with Specter, but I prefer pull syntax to that

ghaskins20:01:46

This is probably a noob fail, but I am struggling to return all attributes for specific entity for which I know the index value of

marshall20:01:12

by know the index value, you mean you have the entity ID?

ghaskins20:01:33

no, but :refdata/symbol is indexed

ghaskins20:01:58

no matter what I try, the pull is not happy with the attribute spec

marshall20:01:47

[:find (pull ?e `[*]) 

marshall20:01:54

then your in clause

ghaskins20:01:01

ah, the backtick might be the thing I was missing

marshall20:01:33

you actually shouldnt need the backtick

marshall20:01:38

sorry, that was a typo

marshall20:01:59

see the example here:

[:find (pull ?e [:release/name]) (pull ?a [*])
 :in $ ?artist-name
 :where [?e :release/artists ?a]
        [?a :artist/name ?artist-name]]

ghaskins20:01:16

hmm, yeah, ive been trying that but it doesnt work

marshall20:01:39

your example shows your syntax differing

marshall20:01:48

no need for the [(datomic/pull

ghaskins20:01:08

I am getting this: "java.lang.IllegalArgumentException: Argument [*] in :find is not a variable"

ghaskins20:01:34

and I just cant spy my error, nor bash it into submission, heh

ghaskins20:01:09

yeah, the vector notation was an act of desperation

marshall20:01:22

try this:

(datomic/q '[:find (pull ?e [*])
             :in $ ?symbol
             :where [?e :refdata/symbol ?symbol]]
            db
            symbol)

ghaskins20:01:34

in this case, the cardinality is 1:1 with the symbol but I was just trying that

marshall20:01:22

np :thumbsup:

ghaskins20:01:27

that was the opposite of obvious 😉

ghaskins20:01:31

thank you very much

ghaskins20:01:50

out of curiosity, is the (pull) form some kind of special form in this context, or is it merely that the datomic/ ns was not valid in the transactor context and datomic is implicitly :refer :all ?

ghaskins20:01:17

e.g. can I run arbitrary clj in the :from as long as its ns-resolved properly?

ghaskins20:01:32

or is the language constrained to specific keywords

ghaskins20:01:10

i suppose I can experiment to find out

ghaskins20:01:23

nope...i tried (datomic.api/pull) form and it wont take it

ghaskins20:01:33

it seems (pull) is special case

tjtolton21:01:00

so, trying to import all my company's data into datomic to get an idea of how many datoms it will look like, and so that I can demo using datomic. Is there a "day of datomic" section about importing data?

marshall21:01:35

@ghaskins Sorry - I got pulled away. No pun intended. Correct, you can’t run arbitrary code in the find specification. You can see the allowed forms in the grammar here: http://docs.datomic.com/query.html#grammar

marshall21:01:16

You can define a custom aggregate function, but it will require some specific parameters

jaret21:01:23

@tjtolton http://stackoverflow.com/questions/27778339/migrate-to-datomic-from-postgres specifically check out the video Ben links in edit to his answer. We don't have a day of datomic like tutorial, but hopefully that answer and the video will help.

tjtolton21:01:52

awesome! Thanks!