Skip to content

:insert-ignore

The :insert-ignore transact form allow you to insert rows, but on :unique key conflict, discard the new row and keep the old.

(def db (rel/mat {} [[:from :Customer] [:unique :id]]))

;; if there is no conflict, its just insert
(def db (rel/transact db [:insert-ignore :Customer {:id 42, :name "bob", :age 33}}]))
;; => 
{:Customer #{{:id 42, :name "bob", :age 33}}}

;; with a conflict, the new row will be discarded.
(rel/transact db [:insert-ignore :Customer {:id 42, :name "alice"}])
;; =>
{:Customer #{{:id 42, :name "bob", :age 33}}}

See also :insert-or-merge, :insert-or-replace, :insert-or-update, :update.