Fork me on GitHub
#datomic
<
2017-04-28
>
Ethan Miller08:04:28

can anyone tell me how i'd dynamically create a transaction spec? i want to do something like:

(defn latest-query
  ([] '[:find (pull ?e [*]) :where [?e :arb/doctype]])
  ([doctype]
   (let [doctype-attr (keyword "doctype" doctype)]
    `[:find (pull ?e [*])
      :where [?e :arb/doctype ~doctype-attr]])))
But this doesn't work since the syntax quote creates a mess of stuff that doesn't belong due to the namespacing:
[:find
 (datemo.routes/pull datemo.routes/?e [clojure.core/*])
 :where
 [datemo.routes/?e :arb/doctype :doctype/note]]
On the other hand, using a regular ' wont' work because it doesn't allow for unquoting...

Ethan Miller08:04:16

Actually, just figured out one way to do it that's kind of ugly:

(defn latest-query
  ([] '[:find (pull ?e [*]) :where [?e :arb/doctype]])
  ([doctype]
   (let [doctype-attr (keyword "doctype" doctype)]
    [:find '(pull ?e [*])
      :where ['?e ':arb/doctype doctype-attr]])))

Ethan Miller08:04:26

Maybe there's a nicer way to do this?

val_waeselynck08:04:34

@ezmiller77 what do you mean, 'a transaction spec' ?

Ethan Miller08:04:07

@val_waeselynck I just mean the edn for a transaction...

augustl08:04:05

you mean a query, I guess? 🙂

Ethan Miller08:04:17

I guess the docs call it "tx-data"

augustl08:04:35

you could always just pass it in as a parameter instead of building a data structure

val_waeselynck08:04:45

@ezmiller77 it does look like a query 🙂

Ethan Miller08:04:12

Well @val_waeselynck I dont' really care to quibble about symantics.

augustl08:04:16

[:find (pull ?e [*]) :in [$ ?doctype] :where [?e :arb/doctype ?doctype]]

Ethan Miller08:04:39

@augustl that's a nice soln!

augustl08:04:45

@ezmiller77 only mentioning it because a query and a transaction are fundamentally very different things

augustl08:04:55

if something takes tx-data it certainly does not expect a query 🙂

val_waeselynck08:04:10

@ezmiller77 I don't think it's fair to call it quibbling, you should know the difference just so you can choose between d/q and d/transact

augustl08:04:12

as in, Datomic is not like SQL where you use the same system for reading and writing, they are pretty different

val_waeselynck08:04:38

but hey, sorry to have interrupted you with my quibbling. good day!

augustl08:04:46

@ezmiller77 the advantage of parameterizing the query is that datomic will cache the query as well

augustl08:04:22

it means that db and doctype needs to be passed in to latest-query of course

augustl08:04:27

that makes more sense to me at least

augustl08:04:17

I'd also rename doctype-attr to doctype-val 🙂

augustl08:04:32

I would say that the attr here is :arb/doctype

Ethan Miller08:04:59

right you are.

kjothen15:04:44

Does anybody know if it's possible to backup/restore and rotate log files to an S3-compatible store? I don't see a way of specifying an endpoint URL in the command line tools, and all attempts so far have resulted in the default http://s3.amazonaws.com endpoint appearing in the logged exceptions.

dominicm15:04:21

I think the aws build for datomic does this / can do this.

dominicm15:04:25

We seem to have a aws-s3-log-bucket-id in aws.properties

dominicm15:04:35

afaik it only runs every 24h

kjothen15:04:37

@dominicm Yes, I've specified a custom address in the aws-s3-log-bucket-id property but it's ignored. The implementation seems fairly determined that the s3 host name is http://s3.amazonaws.com, whereas I need to specify an alternative host name for a compatible s3 store that we run internally.

dominicm15:04:10

ah, I missed s3-compatible.

marshall15:04:35

@kjothen It isn’t currently possible to specify a non-s3 but s3-compatible endpoint for log rotation I’d recommend that you request it as a feature in the customer feedback portal (Suggest Features link in the top nav of my.datomic dashboard)

kjothen15:04:55

@marshall I figured this was the case, but thought I'd check nonetheless. AWS is not an option at my workplace just now, but figured I could take advantage of our internal S3 store for backups in particular. I'll raise some feedback - thanks!

marshall15:04:39

@kjothen yep, totally understand the desire/feature - definitely think it’s one to put on the portal

kjothen16:04:19

@marshall I followed your suggestion and raised the feature in the portal, thanks again for your prompt response

robert-stuttaford15:04:11

@marshall have any of the portal requests become released features yet?

marshall15:04:07

i believe you can click on ‘released’ or ‘releases’ to see which ones

marshall15:04:42

log in mem db was one