Fork me on GitHub

does anyone else struggle with having to deal with both {:person/house {:house/id 1}} and {:person/house 1} in their code? like you probably store :person/house as an integer in your database right, but do you use it as a map everywhere else in your code?


this is overloading the semantics of person/house, which is a bad thing, my suggestion is to make the id field be person/house-id, so they have different names


oh... I may have some schema changes to run


and what happens if you decide it's ok as an integer at first, but then you want to promote it to its own type/ident?

Ben Grabow13:12:53

I typically follow the rule of "give different things different names". Instead of reusing the same name for a new type of information, I create a new name for the new thing. For example, without being creative with the names, I might do something like this for your example:

;; Initial schema
{:person/house 1}

;; Accrete a new attribute to the schema
{:person/house 1
 :person/house-map {:house/id 1}}