This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-09
Channels
- # announcements (20)
- # beginners (115)
- # calva (2)
- # clj-kondo (1)
- # clojure (48)
- # clojure-uk (21)
- # clojurescript (20)
- # css (1)
- # cursive (3)
- # datascript (11)
- # datomic (6)
- # duct (26)
- # emacs (5)
- # funcool (6)
- # off-topic (45)
- # perun (1)
- # precept (4)
- # quil (2)
- # re-frame (1)
- # shadow-cljs (251)
- # tools-deps (27)
- # uncomplicate (9)
Hi there, I have a question...I have data in this shape:
({:product/code "42"
:sku/code "1"
:product/names [{:product/name "Camera"
:language/iso-639-1 "en"}
{:product/name "Appareil"
:language/iso-639-1 "fr"}]
:product/type "Camcorders & Digital Cameras"}
...)
and schema
(def schema {:product/code {:db/unique :db.unique/identity}
:product/names {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}
:language/iso-639-1 {:db/valueType :db.type/ref
:db/isComponent true}})
Is it expected that I see these datoms?
[1 :product/code "42" 536870913 true]
[1 :product/names 2 536870913 true]
[1 :product/names 4 536870913 true]
[1 :product/type "Camcorders & Digital Cameras" 536870913 true]
[1 :sku/code "1" 536870913 true]
[2 :language/iso-639-1 3 536870913 true]
[2 :product/name "Camera" 536870913 true]
[4 :language/iso-639-1 5 536870913 true]
[4 :product/name "Appareil" 536870913 true]
If yes, why is it not showing me the language in:
(datascript/pull db ["*"] 3)
=> #:db{:id 3}
In the above the entity 3
should have attribute "en"
but I never see it in the list of datoms
(`5` is "fr"
)
I am basically trying to have one datom per :language/iso-639-1
and refer to those from the product/name
Oh I see, if it's a ref I cannot really go back to the values - kind of makes sense
I wonder how I can model that now though
(as a note, I am letting datascript create the entities, no :db/add
on my side)
uhm...I see I receive back some
(:tempids txs)
{"en" 3, "fr" 5, :db/current-tx 536870913}
still not clear ... digging diggingfor my problem above, I am still trying to understand how to model, it feels like I need a composite key [:product/name :language]
- is it something you usually do in datascript/datomic?