Fork me on GitHub
#datomic
<
2020-03-20
>
v17:03:26

@favila Quick question. How do I start the datomic UI console. This is the URI from my transactor

datomic:

v17:03:32

I frist tried starting the peer server by running

bin/run -m datomic.peer-server -h localhost -p 9001 -a myaccesskey,mysecret -d helloo,datomic:

v17:03:00

Then next I ran

bin/console -p 8084 helloo datomic:
to start the console, the UI opens. but when I choose DB, I get this error
java.lang.RuntimeException: Could not find hello//hello in catalog

favila17:03:18

the console and peer server are unrelated

favila17:03:57

try `

bin/console -p 8084 localhost-postgres datomic:sql://?jdbc:

🎉 4
favila17:03:20

note, the alias here is not a db alias, but a “storage” alias (i.e. all the dbs managed by a transactor)

🎉 4
favila17:03:29

and you don’t specify the db name in the uri

favila17:03:39

(because console can access all dbs)

v18:03:09

Thank you so much 🙂

drewverlee17:03:01

Is there an easy way to construct the where clause for a query? Like conditionaly i want this where clause or this one.

favila17:03:59

cond-> and a steady hand

favila18:03:23

is it not an appropriate use for a or or rule?

drewverlee18:03:59

gotcha. I was trying to remember how programmatic queries worked. https://docs.datomic.com/on-prem/query.html#building-queries-programmatically

drewverlee18:03:18

The other options you mentioned might work to for my case.

favila18:03:08

but not always. ad-hoc filters is one case where it’s just easier and more predictable performance to add/remove clauses

favila18:03:29

but keep clause order deterministic, so you can still leverage caching

dustingetz13:03:56

@drewverlee you want backtick https://github.com/brandonbloom/backtick

(let [needle "foo"]
  (template
    [[(clojure.string/includes? ?name ~needle)]]))
=> [[(clojure.string/includes? ?name "foo")]]
Yes be sure that you aren’t blowing out number of static queries, parameterize them appropriately if possible, injecting a string constant in this way would be a really bad idea, but injecting a clause based on a predicate would be fine as it emits only two possible queries

drewverlee14:03:45

What i feel i need to express is the idea of conditionally picking the part of the where clauses. d/q [:find ?x :where [?a :fname "drew"] (if some-conditional [?a :lname "verlee"] [?a :age 15] I think i need to insert the entire clause(s) as opposed to just an entity, attribute or value.

favila14:03:21

is this because you have a multiparameter search interface, and some fields can be unused?

favila14:03:40

Just wondering what your use case is. What you wrote here is possible but not the best--parameterization is better; conditionally emitting clauses can sometimes be ok but still using parameterization

dustingetz13:03:56

@drewverlee you want backtick https://github.com/brandonbloom/backtick

(let [needle "foo"]
  (template
    [[(clojure.string/includes? ?name ~needle)]]))
=> [[(clojure.string/includes? ?name "foo")]]
Yes be sure that you aren’t blowing out number of static queries, parameterize them appropriately if possible, injecting a string constant in this way would be a really bad idea, but injecting a clause based on a predicate would be fine as it emits only two possible queries