Fork me on GitHub
#datomic
<
2016-10-11
>
robert-stuttaford04:10:03

think about it, @hueyp — it’ll always be a coll. several things may have entity alpha as its one thing. having datomic enforce that only one thing has entity alpha adds a lot of busy-work to quite a lot of the api for not much gain.

hueyp04:10:58

wasn’t sure if there was some unique constraint magic I didn’t know about is all (you can get the behavior with components)

odinodin08:10:28

I’m having trouble using Clojure spec to validate Datomic entities, specifically using clojure.spec/keys since that requires the input to be a map. Any thoughts on that?

odinodin08:10:29

Here’s a simple example:

(s/def ::age number?)
(s/def ::name string?)

(s/def ::person (s/keys :req [::name ::age]))

(def person-entity (d/entity (d/db conn) [:person/name "Mr entity"]))

(s/explain ::person person-entity)

val: #:db{:id 17592186069950} fails spec: :some-ns/person predicate: map?

danielstockton08:10:49

You could call d/touch on the entity first

odinodin08:10:33

@danielstockton that is still not a map

odinodin08:10:03

I’ve made some progress with using a conformer together with and

odinodin08:10:22

basically this:

(defn to-map [input]
  (if (= (type input) EntityMap)
    (d/pull (d/db conn) '[*] (:db/id input))
    input))

(s/def ::person2 (s/and (s/conformer to-map) ::person))

danielstockton09:10:45

That looks OK, what's missing?

odinodin09:10:20

the trouble with pull * is that it only goes one level down

danielstockton09:10:35

touch works more than one level deep, right? so that might work, if you can convert the touched EntityMap into a clojure map

danielstockton09:10:12

i thought that pull also worked for nested entities

odinodin09:10:30

I'm looking for a generic solution for how to use spec with datomic, and I'm thinking my current solution is not the best way to go about it

danielstockton09:10:43

count me also interested

kristian09:10:15

@odinodin this “trick” will solve your problem

odinodin09:10:51

@borkdude: interesting. However, I also want it to work with fdef

martinklepsch13:10:38

Is there a way to have a persistent datomic database without a separate transactor process? (for development)

jaret14:10:56

@martinklepsch Persistent requires you to use a separate txor via DEV or FREE protocol. If persistent is not a requirement you can use MEM protocol.

martinklepsch14:10:10

ok. hoped there might be something that doesn't require me to start another process

martinklepsch14:10:32

but it's a database after all so I probably should just accept it 🙂 thanks @jaret

pesterhazy14:10:40

welcome to the wonderful world of datomic, @martinklepsch !

robert-stuttaford19:10:03

yeah, so if you update to the latest version of datomic, make very sure to update your aws-sdk too 🙈