This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-27
Channels
- # announcements (1)
- # beginners (54)
- # biff (7)
- # calva (6)
- # cider (7)
- # clojure (9)
- # clojure-art (3)
- # clojure-europe (27)
- # clojure-gamedev (16)
- # clojurescript (15)
- # editors (2)
- # emacs (1)
- # events (1)
- # fulcro (24)
- # gratitude (23)
- # humbleui (6)
- # lsp (9)
- # malli (3)
- # off-topic (52)
- # pathom (5)
- # portal (1)
- # rdf (9)
- # reveal (3)
- # shadow-cljs (52)
- # specter (2)
- # tools-build (9)
- # tools-deps (11)
- # tree-sitter (1)
- # xtdb (21)
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
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?
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}}