Fork me on GitHub
#clara
<
2020-06-19
>
PB14:06:16

Hey all, is there a way to insert multiple records inside of a rule, one for each item in a list. Sorry, I think I'm not sure how to properly ask this but I think my example should describe this pretty well:

(defrule somerule
  [SomeRecord  (= ?list-of-ids list-of-ids)]
  =>
  (for [id ?list-of-ids]
    (insert! (->Addition id :some-key "icecream"))))

mbragg14:06:07

There is insert-all!that accepts a sequence of facts which may be useful to you https://cljdoc.org/d/com.cerner/clara-rules/0.20.0/api/clara.rules#insert-all!

PB14:06:54

@mbragg yes! but how do I generate that sequence of facts? It does not allow me to iterate over ?list-of-ids

PB14:06:52

Oh, I was wrong, I was really tired last night. Thank you @mbragg