This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-27
Channels
- # ai (4)
- # beginners (102)
- # boot (216)
- # cider (20)
- # cljs-dev (9)
- # clojure (130)
- # clojure-russia (4)
- # clojure-spec (9)
- # clojure-uk (11)
- # clojurescript (59)
- # core-async (2)
- # cursive (10)
- # datomic (51)
- # figwheel (1)
- # flambo (3)
- # hoplon (2)
- # luminus (1)
- # om (17)
- # om-next (4)
- # onyx (2)
- # perun (2)
- # re-frame (79)
- # ring (5)
- # ring-swagger (9)
- # rum (3)
- # schema (3)
- # specter (9)
- # untangled (3)
- # vim (1)
I want add data like [{:pl “a” :en “b”}{:pl “c” :en “d”}]
what choice of schema i have? Not sure how to operate on vector of maps in datomic 🙂
@kwladyka, at my company we came up with a pattern
:product/name
, :product/description
are in English
:product/translations
is a ref and points to a "translation" entity with all the same fields
{:db/id ... :
that's of course assuming that there's a primary language (in our case, English)
it works for us, but I'm curious how others work with i18n in Datomic
I think our pattern is actually relatively simple
the problem of course is that you need a relation with a primary key consisting of product_id
and language
(in SQL terms)
why not refer the :product/name
:product/description
etc. instead of :product/translation
?
that would work too, but it's convenient to have the English name attache directly to the entoty
i prefer to not stick to any language, because my native language and country doesn’t have english language as primary
same for me, but our company does have a primary lang
anyway… is it possible to just save vector of maps in datomic in any way? Just to start from scratch?
you can only store EAV tuples
you cannot store a vector, but you can store a set of refs
then you need to store a position
attribute too
AFAIK, though maybe there's some other smart way
it's not that bad, but you need to do the sorting yourself (in clojure code, outside of d/q
)
i mean i can add this, but it will be nice to write/read in datomic in the same order without adding additional position
value
let me know if you discover a better way
The other option for ordering is to store things as a ‘linked list’ (i.e. each entity has a ‘next’ ref) instead of storing an index explicitly with each individual entity
so you'd use a recursive query to get all the elements?
yep. Since all the work of query is local to the peer and caching provides local access, you don’t have to worry about the n+1 problem the same way as you would with a traditional DB
of course, the decision is similar to that of array vs linked list for a data structure - each is better at some things and worse for other things
interesting. at first glance it sounds scary, because of the danger of circular lists
If order is an "insertion order", then one does not need a separate attribute and might use transaction id for sorting.
@dottedmag also correct - if you don’t need to “update” it later
@pesterhazy You can always limit the recursion (i.e. with pull)
@dottedmag true, if you’re using tx id - that also mandates that you transact each entity in a separate transaction
relying on txid works but can be limiting if you want to dump/restore portions of dbs
e.g. a development snapshot of the prod db, or just copying a few products from one, say, supplier to another
is there some best practice for stringing together datomic queries... I have a situation where i'd like to provide the customer with a variable number of filters. I have tried passing some DIY syntax to the backend and reducing the client inputs into one large datomic query, and it works with some success however the code looks quite brittle and I've yet to apply any appropriate order of executing queries (biggest diffs to smallest diffs)... So I was just wondering if anyone had any recommendations basically about how to abstract a datomic query into modular filters.
like the basic problem is... let's say i wanted someone to search for User entities. I provide a search by email, name, city inputs. On the backend the combinations of email,name,city could result in 8 or 9 defined query functions. ['name', 'city', 'email', 'name,city', 'city,email'] etc etc
@pesterhazy can you show me shema and how you operate on this data structure? For now i have https://www.refheap.com/9347805f7fb2e7604e132f761
i am learning datomic and after thinking what you said me.... i am confuse how it work