This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-28
Channels
- # adventofcode (2)
- # announcements (4)
- # babashka (34)
- # beginners (44)
- # biff (5)
- # calva (8)
- # cider (4)
- # clj-kondo (5)
- # clj-on-windows (5)
- # clojure (57)
- # clojure-art (1)
- # clojure-denmark (2)
- # clojure-europe (40)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-seattle (1)
- # clojure-uk (2)
- # clojurescript (20)
- # cursive (6)
- # datomic (1)
- # emacs (6)
- # events (5)
- # fulcro (22)
- # helix (5)
- # hyperfiddle (5)
- # jobs (1)
- # joyride (2)
- # lsp (8)
- # malli (8)
- # off-topic (30)
- # pathom (8)
- # pedestal (1)
- # portal (5)
- # proton (1)
- # rdf (2)
- # re-frame (4)
- # releases (1)
- # remote-jobs (1)
- # reveal (8)
- # xtdb (5)
Howdy all, Coding novice here, after some data modeling feedback. Let's say I'm building a site that lists gift shops and the currencies they accept. I could store each currency code as a string in the store's document:
:store/id uuid
:store [:map {:closed true
[:store/currency [:vector [:string]]]
...
but I imagine that could get messy (multiple opportunities for an admin to mistype a code etc).
So my question is, where the data is both finite and known e.g currency codes. Is it better to create a new document and reference it by id.
:currency/id uuid
:currency [:map {:closed true}
[:currency/country :string]
[:currency/code :string]]
:store/id uuid
:store [:map {:closed true}
[:store/currency [:vector [:currency/id]]
[:store/name :string]]]
:thinking_face:Malli has an enum type that would work nicely. e.g. update first example to :store/currency [:enum :usd :eur ...]
. If you're only dealing with a small total number of currencies, you could do that as-is. If you want to support all the currency codes, you could define them in a separate var, e.g. (def currencies [:usd :eur ...])
and then do :store/currency (into [:enum] currencies)
.
Super useful, thank you. Takes care of the follow up question I had WRT handling small vs large property lists