Fork me on GitHub

I’ve been putting some hammock time into how one might spec a datomic entity, and right now I’m pondering what spec’s conformance might mean for an entity. My first impulse was that they would conform to maps, which might work. But then, I’m unsure if s/unform from a map to an entity is a valid concept, because for example, the resulting entity wouldn’t have anything to return from d/entity-db. I’m also not sure if there’s even a way to create an entity outside of a database context. Anyone have any thoughts on any of this?


@bhagany my bigger issue w/ speccing datomic is that the thing you hold in-memory might not be the whole entity. In spec if you say (s/keys :req [::foo ::bar]), you’re saying in-memory this must have :foo, :bar, which is different from saying the entity must have :foo, :bar. So IMO spec is fine for specific DB queries, but not for general purpose validation


though you might be able to do something with transactor functions


in my head, the spec would realize keys in memory as it checked for them


just like normal key access for entities


I think that isn’t too different from what you’d expect from validating other lazily evaluated things


so then you have an implicit pull on every validate?


that will work in some applications, but not all


More like an implicit touch, but yes, it would potentially be the entire database


But if you spec the whole db, that's kind of expected