This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-23
Channels
- # aleph (9)
- # beginners (30)
- # boot (42)
- # carry (1)
- # cider (148)
- # clara (2)
- # cljsrn (13)
- # clojars (2)
- # clojure (90)
- # clojure-dev (1)
- # clojure-dusseldorf (2)
- # clojure-italy (7)
- # clojure-madison (1)
- # clojure-quebec (1)
- # clojure-russia (19)
- # clojure-sg (1)
- # clojure-spec (14)
- # clojure-uk (90)
- # clojurebridge (1)
- # clojurescript (70)
- # clr (7)
- # core-async (24)
- # cursive (26)
- # data-science (2)
- # datascript (3)
- # datomic (46)
- # devops (2)
- # emacs (6)
- # events (1)
- # figwheel (2)
- # hoplon (200)
- # klipse (2)
- # ldnclj (1)
- # lein-figwheel (4)
- # leiningen (3)
- # off-topic (44)
- # om (70)
- # other-languages (6)
- # pedestal (5)
- # protorepl (1)
- # re-frame (17)
- # reagent (14)
- # schema (2)
- # spacemacs (1)
- # specter (3)
- # test-check (38)
- # unrepl (38)
- # untangled (19)
- # yada (16)
@hendriklouw your query has O(n^2) complexity
you're scanning every (person, person) pair
try this instead
this one has O(n) complexity
nice, that works perfectly. Thank you @val_waeselynck
could anyone possibly explain a use case for db.type/ref
?
might make sense in the context of a cardinality many attribute, e.g. a person might have multiple addresses
okay... so the "value" of such a datom would be another entity?
when you transact a value you can use the other entity ID directly, or a lookup ref (see http://blog.datomic.com/2014/02/datomic-lookup-refs.html)
like if I had a user and I had a project and I wanted to make a schema for the project owner, that would probably be a :db.type/ref
with the user as the owner?
gotcha, thank you!
okay let's say I have a bunch of schema {:db/ident user/attr ...}
... is it is possible to query all attributes that are available for user/*
?
ah okay
maybe I should be more clear I'm not looking for the attributes for any specific entity just all the attribute fields that relate to user
I mean I can clearly see them in the console but I'm wondering if there's a programmatic way to get them
you could probably do something with database functions in a datalog query, e.g. starts-with?
okay let me rephrase... is there a way to query over all the attributes and just get the ones that have :user
as the beginning of their keyword?
ah I see
agreed -- just feeling my way around
[:find [?attr-ident ...]
:where
[:db.part/db :db.install/attribute ?attr]
[?attr :db/ident ?attr-ident]
[(namespace ?attr-ident) ?attr-ns]
[(= ?attr-ns "user")]]
interesting... is the ...
significant?
okay, awesome 😄
now when I run this I'm getting Don't know how to create ISeq from: clojure.lang.Keyword
... could that just be because I haven't populated any data yet?
I'm looking up the docs I'm just trying to figure out which part of that query is supposed to be literal and which I'm supposed to fill in values for... e.g. in the :db.part/db
am I supposed to put in the name of the db or is that a literal?
also @favila what are you up to like 5 beers that I owe you now? 😂