Fork me on GitHub
#datomic
<
2020-04-11
>
Drew Verlee03:04:38

I'm using datomic cloud and i get the exception "http://grow.de I dont understand what the that means? why isn't it allowed? i assume their is something wrong with the function. Backing up, the goal is to enforce that every floor has a building. This is just a learning exercise, so i'm open to any interperation of how it would be best to solve this. code:

(defn floor-has-one-building-v4?
  [db eid]
  (let [building (d/pull db '[{:building/_floor [:building/name]}] eid)]
    (= (count building) 1)))

(def predicate
  {:db/ident        :floor/guard4
   :db.entity/attrs [:floor/name]
   :db.entity/preds 'grow.dev/floor-has-one-building-v4?})

(comment
  (d/transact conn {:tx-data [predicate]}))

(d/transact conn {:tx-data [{:building/name  "Big Building"
                             :building/floor [{:floor/name "bottom"
                                               :db/ensure  :floor/guard4}]}]})

Joe Lane15:04:14

I second what ghadi said. I just noticed that your "exception" message says "... by datomic/on/config". If that isn't a slack typo, it needs to be datomic/ion-config.edn (per https://docs.datomic.com/cloud/ions/ions-reference.html#ion-config)

👍 4
ghadi03:04:22

@drewverlee entity predicates need to be on the classpath of the primary compute group

ghadi03:04:43

and mark them under the :allow section

ghadi03:04:52

entity preds do not run on the client submitting the transaction, they run on the server (the primary/transactor)

murtaza5207:04:00

Below is from the datomic documentation -

The V-leading index VAET supports efficient queries for references between entities, analogous to a graph database.

The combination of EAVT and VAET supports arbitrary nested navigation among entities. This is like a document database but vastly more flexible. You can navigate in any direction at any time, instead of being limited to the containment hierarchy you selected when storing the document.
The above tells me that datomic is a good fit where the data is being modelled as a graph / document. Are there any examples of graph data / document data being modelled in datomic ? Most examples I see is of relational / cloumnar types.

potetm14:04:16

@murtaza52 There’s a lot of overlap there. For a document store, you just need an entity identifier and some attributes on that entity. For graphical data, you just need to reference other entities (via :db.type/ref).