 (defprotocol IOperation
   (-execute [_ conn txid] "Execute the operation."))
 
-(deftype AddOperation [partition attr value]
+(deftype EntityOperation [partition eid]
+  IOperation
+  (-execute [_ conn txid]))
+
+(deftype AddOperation [partition eid attr value]
   IOperation
   (-execute [_ conn txid]
     (let [table (attrs/-normalized-name attr partition)

          sqlv  [sql eid txid value]]
      (sc/execute conn sqlv))))

(deftype RetractOperation [partition attr value]
  IOperation
  (-execute [_ conn txid]
    (let [table (attrs/-normalized-name attr partition)

    ;; TODO: exclusive share lock
    (func conn)))

(defn transact
  [context facts]
  (let [ops (compile-ops context "user" facts)
        conn (.-connection context)]
    (run-in-tx conn #(run-tx % ops))))
