Fork me on GitHub
#datomic
<
2018-11-15
>
bmabey03:11:35

Is it possible to develop ions using a standalone/local datomic (in memory or otherwise) DB? (I don't always have internet access when programming 🚌)

lwhorton10:11:37

i was thinking about this the other day, but i don’t know. if i had to guess, no. we’re working with something called “_ cloud” which i figure is a pretty good excuse to not have an offline story

Joe Lane14:11:13

@U5QE6HQK0 I mean, you can develop your codebase, you just can’t connect to the database. If you wanted to mock things out you practice tdd to work on Biz Logic.

👍 4
dpsutton14:11:20

i've got some attributes like the following:

{:response/id 4
 :response/items [...]
 :response/request {:request/id 4
                    :request/items [...]}}
and i'm trying to query for response/request pairs where the item counts are different. ie, the request talked of 5 items but the response talks only of 2. My first stab at it has been like so
(d/q '[:find ?request
       :in $
       :where
       [?response :response/items ?resp-items]
       [(count ?resp-items) ?resp-item-count]
       [?response :response/request ?request]
       [?request :request/items ?req-items]
       [(count ?req-items) ?req-item-count]
       [(!= ?resp-item-count ?req-item-count)]]
     db)
but this is trying to take the count of a long which makes sense but i'm not sure how to tweak it to count the collection

marshall14:11:48

Every clause operates on each individual element that matches a given logic variable. So you’re counting the entityIDs (which are bound to resp-items)

marshall14:11:05

I would use a nested query for this case

marshall14:11:15

put the count in the find clause of the nested query

dpsutton14:11:44

thank you very much marshall

schmee14:11:14

doesn’t look like it’s trying to take the count of a long? are you getting any errors or just no results?

dpsutton14:11:38

?resp-items is an id and (count 4) blows up

uwo21:11:32

here’s a naive little utility fn for pull expressions that I find myself reaching for during development. let me know if there’s another (likely better and more full) implementation out there! https://gist.github.com/uwo/9ae7a83737093dd59b6a1c6086cc0837

favila22:11:00

I'm not clear on the input to this. You give it the result of a pull (maps of keywords to vectors-of-maps) and it gives you the pull expression that would pull the same data?

Dustin Getz23:11:06

As to whether to drive datomic utils by polymorphism or by schema, I have learned the hard way to just always use schema and stop thinking about it. There are too many edge cases. We have a whole graveyard of implementations with comments like "todo isComponent" and "todo lookup refs" etc.

metal 4
uwo14:11:53

@U09R86PA4 yep. for some reason I often have a concrete tree of data on hand and don’t want to spend a bunch of time writing the pull expression that would generate it. It usually just serves as a starting point, not something I do dynamically in production code

favila14:11:58

I have a similar one that makes a pull from a let map destructure

🙏 4
uwo19:11:24

nice! gist?

Dustin Getz23:11:06

As to whether to drive datomic utils by polymorphism or by schema, I have learned the hard way to just always use schema and stop thinking about it. There are too many edge cases. We have a whole graveyard of implementations with comments like "todo isComponent" and "todo lookup refs" etc.

metal 4