Ask questions on the official Q&A site at https://ask.datomic.com!
vncz 2020-10-28T00:09:10.194500Z

Understood. I must have understood incorrectly then. I recall a video saying something different

vncz 2020-10-28T14:21:24.195100Z

Is there a way to DRY these two queries? They look almost identical apart from the id parameter. Is there a way without having to manipulate the list manually?

vncz 2020-10-28T14:23:38.195800Z

Well I can probably get away with it by using the map form, but I was wondering whether there's a better way :thinking_face:

ghadi 2020-10-28T14:24:17.196300Z

Use d/pull directly with the first form

ghadi 2020-10-28T14:24:42.196800Z

Rather than pull in the find spec of a query

vncz 2020-10-28T14:24:49.197100Z

Ok fair

vncz 2020-10-28T14:29:47.198100Z

I was thinking that if I would be switching to map form I could manipulate the query easily and add the parameter?

favila 2020-10-28T14:49:36.198200Z

pull (and most things) can take any entity identifier, which includes entity ids, idents, and lookup refs. In your case, (d/pull db [:person/id :person/name :person/surname] [:person/id "the-id"]) would work

favila 2020-10-28T14:55:56.198400Z

I question whether this is better, but it is DRY:

favila 2020-10-28T14:56:04.198600Z

(defn people [db person-pull person-ids]
  (d/q '[:find (pull ?e person-pull)
         :in $ person-pull ?ids
         (or-join [?e ?ids]
                  (and [(= ?ids *)]
                       [?e :person/id])
                  (and [(!= ?ids *)]
                       [(identity ?ids) [?id ...]]
                       [?e :person/id ?id]))]

favila 2020-10-28T14:56:21.198800Z

use the special id value * to mean “everyone”

favila 2020-10-28T14:56:43.199Z

otherwise it’s a vector of entity identifiers

vncz 2020-10-28T15:07:56.199300Z

Ah interesting, that I didn't know. Thanks!

vncz 2020-10-28T15:08:54.199500Z

Hmm does not seem worth the hassle. I was thinking of using the map form and manually inject the parameter @favila …what do you think?

favila 2020-10-28T15:10:50.199700Z

there may be a penalty from not caching the query plan, since each query is a new instance. But I’m not sure if cache lookup is by identity or by value

Aleh Atsman 2020-10-28T15:43:03.200900Z

Hello, can somebody clarify for me the purpose of cast/event , is it only for infrastructure level events or can it be used for application level events as well?

Aleh Atsman 2020-10-29T14:08:59.217700Z

Hello @joshkh, @jaret! Thank you for explanation. In the end we decided to go with event bridge or sns topic directly. It is problematic to route events from cloudwatch logs to aws lambda functions. As the only option there is subscription filter (max 2 per log group). Maybe I missing something, but haven't found solution where I am able to get events submitted using cast/event to lambda functions.

joshkh 2020-10-29T14:20:31.220300Z

i don't know if this is useful to you, but we cast/alert exceptions to CloudWatch, and then use a CLJS Lambda to send them to Slack to torture our developers. cast/events are not really any different, except for maybe the frequency at which they appear, but i think log streams are batched. (sorry for the lack of a proper README, it was a hobby project) https://github.com/joshkh/datomic-alerts-to-slack > It is problematic to route events from cloudwatch logs to aws lambda functions. As the only option there is subscription filter (max 2 per log group). for application level logs and alerts, we tend to the use a common message throughout the application (e.g. {:msg "<app-name>-application-log"} ) , and then we attach other keys such as :env and :query-group . this provides us different levels of filtering while keeping our logs all in one place

joshkh 2020-10-29T14:22:23.220600Z

but if SNS works for you then go for it! 🙂 i just prefer CloudWatch because cast serialises Clojure to JSON very well, and being able to add arbitrary keys at any level is useful for filtering

vncz 2020-10-28T16:11:49.201600Z

Got it. good point. Seems like a case where duplication is cheaper than the wrong abstraction 🙂

joshkh 2020-10-28T17:10:37.201800Z

someone else can correct me if i'm wrong, but i use cast/event for all sorts of things including application level logging

jaret 2020-10-28T18:16:37.202Z

@aleh_atsman to echo what Josh is saying it's for ordinary occurrences of interest to the operator. Whereas an Alert is for an extraordinary occurrence that requires operator intervention. These are conventions you can choose to follow or not in your use of the ion.cast.