(insert session [id attr value])
(insert session id attr->value)
(insert session id attr value)
Inserts a fact into the session. Can optionally insert multiple facts with the same id.
Note: if the given fact doesn't match at least one rule, it will be discarded.
Examples
Insert facts separately
(->
session
(insert 1 :todo/text "Wash the car")
(insert 1 :todo/done false)
(insert 2 :todo/text "Buy groceries")
(insert 2 :todo/done false)
query-all)
Insert facts batched by id
(->
session
(insert 1 {:todo/text "Wash the car", :todo/done false})
(insert 2 {:todo/text "Buy groceries", :todo/done false})
query-all)
Source
(defn
insert
"Inserts a fact into the session. Can optionally insert multiple facts with the same id.\n \n Note: if the given fact doesn't match at least one rule, it will be discarded."
([session [id attr value]] (insert session id attr value))
([session id attr->value]
(reduce-kv
(fn [session attr value] (insert session id attr value))
session
attr->value))
([session id attr value]
(->>
(get-alpha-nodes-for-fact
session
(:alpha-node session)
id
attr
value
true)
(upsert-fact session id attr value))))