This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-05
Channels
- # aws (1)
- # beginners (57)
- # boot (3)
- # cider (6)
- # clara (49)
- # cljs-dev (47)
- # cljsjs (23)
- # clojure (144)
- # clojure-dev (2)
- # clojure-finland (1)
- # clojure-germany (1)
- # clojure-sg (1)
- # clojure-spec (25)
- # clojure-uk (245)
- # clojurescript (39)
- # core-async (3)
- # cursive (6)
- # datomic (117)
- # emacs (3)
- # fulcro (6)
- # hoplon (10)
- # jobs (7)
- # juxt (5)
- # leiningen (11)
- # om (27)
- # pedestal (4)
- # perun (2)
- # re-frame (22)
- # reagent (35)
- # ring-swagger (11)
- # shadow-cljs (333)
- # spacemacs (10)
- # specter (10)
- # sql (20)
- # vim (8)
hi, I'm still learning fulcro. I'm curious how to do nornalization and queries for the case of many-to-many pattern
{:authors/by-id {"author/1" {:db/id "author/1"
:author/name "Foo"}
"author/2" {:db/id "author/2"
:author/name "Bar"}}
:books/by-id {"book/1" {:db/id "book/1"
:author/name "A book"}
"book/2" {:db/id "book/2"
:book/title "The book"}}
:books_authors/by-id
{"books_authors/1" {:db/id "books_authors/1"
:author [:authors/by-id "author/1"]
:book [:books/by-id "book/1"]}
"books_authors/2" {:db/id "books_authors/2"
:author [:authors/by-id "author/1"]
:book [:books/by-id "book/2"]}}}
should I have a junction table like above?
if yes, then what the query for author and book should look like?
if no, then what is the right way to do it?
@myguidingstar You could simply store a key like :book/author
in books/by-id
pointing to authors like [:authors/by-id "author/1"]
. I would give the excellent online docs here a read: https://fulcrologic.github.io/fulcro/guide.html#!/fulcro_devguide.C_App_Database or you can clone the Fulcro repo https://github.com/fulcrologic/fulcro and run ./run-devguide.sh
in order to be able to play with the devcards as well. When you're reading up on that section I would take note on naming conventions used to reduce redundancy in your example e.g. I would expect an id of 1 instead of "author/1".