Trying to make an excise work

I am trying out excise like this:

First, I create a schema and some test data (I am using the Clojure REPL to run this)

(require '[datomic.client.api :as d])
(def client (d/client {:server-type :datomic-local
                       :system "dev"}))
                       
(d/create-database client {:db-name "vehicles"})
(def conn (d/connect client {:db-name "vehicles"}))

(def vehicles-schema [{:db/ident :customer/id
                              :db/valueType :db.type/uuid
                              :db/cardinality :db.cardinality/one
                              :db/doc "The id of the customer"}

                             {:db/ident :customer/name
                              :db/valueType :db.type/string
                              :db/cardinality :db.cardinality/one
                              :db/doc "The name of the customer"}

                             {:db/ident :customer/vehicles
                             :db/valueType :db.type/ref
                             :db/cardinality :db.cardinality/many}])

(d/transact conn {:tx-data vehicles-schema})

(def test-customers [{:customer/id #uuid "6ea61f1a-32cb-4aa0-8c25-a5614ca2bb10"
                             :customer/name "John Doe"}
                            {:customer/id #uuid "47b8b1bb-7819-445e-abdf-61184192566b"
                             :customer/name "Ada Lovelace"}])
                             
                             
(d/transact conn {:tx-data test-customers})

If I run this query, I can see the 2 customers:

(def db (d/db conn))

(def all-customers-q '[:find ?customer ?id ?name 
                    :where 
                    [?customer :customer/id ?id]
                    [?customer :customer/name ?name]
                    ])
                    
(d/q all-customers-q db)

Result:

[[83562883711053 #uuid "47b8b1bb-7819-445e-abdf-61184192566b" "Ada Lovelace"] [83562883711052 #uuid "6ea61f1a-32cb-4aa0-8c25-a5614ca2bb10" "John Doe"]]

I would now like to excise one of the customers. I tried running:

[{:db/excise 83562883711053}]

I also tried:

(d/transact conn [{:db/excise 83562883711053}])

Every time, when I run (d/q all-customers-q db) after that, I still see the 2 customers. What am I doing wrong?

I also read about sync-excise, but I don’t know how to run that.

After putting this forum post in ChatGPT, I got the response that the excising should be done like this: (d/transact conn {:tx-data [{:db/excise 83562883711053}]})

However, when I try this, I get an error that excision is not supported in Datomic Cloud?

user=> (d/transact conn {:tx-data [{:db/excise 83562883711053}]})
Execution error (ExceptionInfo) at datomic.core.db/add-tempids-to-errors (db.clj:3188).
:db.error/unsupported Excision is not supported in Datomic Cloud.

But I am not using Datomic Cloud, I use a local file system to store the data (Configured via ~/.datomic/local.edn)

Hey Wim,

Excision is only supported in Datomic Pro using the peer api. Datomic local uses the client api and does not support using excision.

I recommend at least testing excision against a dev protocol database as that will mirror other durable storages (ddb sql cass).

Thanks,
Jaret

Added note… now that we have combined our Datomic Pro/Local/Cloud documentation in one place I think this is not as evident when you read our docs. I am going to add something to the top of excision and to the limits of Datomic Local that points this out.

I recommend at least testing excision against a dev protocol database as that will mirror other durable storages (ddb sql cass ).

Can you explain in more detail how I do that? Do I need to change anything to this:

(require '[datomic.client.api :as d])
(def client (d/client {:server-type :datomic-local
                       :system "dev"}))

?

Hey Wim,

You need to be using Datomic Pro and the peer API. You can follow our docs tutorial:

https://docs.datomic.com/peer-tutorial/peer-tutorial.html

After you are comfortable setting up a dev DB you will want to read all of the excision documentation. There are very few reasons to use excision generally and it’s very permanent.

I also put together a quick example using the mbrainz-sample database at this gist to show you an entire excision:

Cheers,
Jaret