Database and entity functions


#1

Hi guys,

When using the Client API (with Datomic Cloud or locally with a Peer Server), is there any way to use the database functions?

I have 2 use cases:

  1. A custom transaction (database) function.
  2. An entity function (i.e. as a :db.type/fn attribute).

Currently, I am getting the following exception when trying to add a function built with (datomic.api/function …):

java.lang.RuntimeException: java.lang.Exception: Not supported: class clojure.lang.Delay

Many thanks,
Mykola


#2

Mykola,

With Datomic Cloud, you’ll need to create your functions as Ions (https://docs.datomic.com/cloud/transactions/transaction-functions.html#custom and https://docs.datomic.com/cloud/ions/ions.html) in order to deploy them to your running Cloud instance.

In Datomic On-Prem, you would need to install your database function in a transaction (https://docs.datomic.com/on-prem/database-functions.html). The day-of-datomic examples include some Peer library code demonstrating this (https://github.com/Datomic/day-of-datomic/blob/master/tutorial/data_functions.clj).