This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-28
Channels
- # arachne (2)
- # aws (5)
- # aws-lambda (5)
- # beginners (4)
- # boot (25)
- # cljs-dev (270)
- # cljsjs (1)
- # cljsrn (72)
- # clojars (5)
- # clojure (201)
- # clojure-belgium (5)
- # clojure-brasil (4)
- # clojure-italy (2)
- # clojure-korea (2)
- # clojure-russia (24)
- # clojure-spec (24)
- # clojure-uk (22)
- # clojurebridge (1)
- # clojurescript (125)
- # cloverage (3)
- # cursive (41)
- # datomic (37)
- # dirac (4)
- # emacs (2)
- # hoplon (421)
- # lein-figwheel (1)
- # leiningen (5)
- # luminus (2)
- # mount (1)
- # off-topic (18)
- # om (44)
- # om-next (4)
- # onyx (44)
- # pedestal (3)
- # proton (9)
- # re-frame (21)
- # reagent (21)
- # ring-swagger (12)
- # specter (9)
- # sql (2)
- # untangled (62)
- # vim (16)
@mlimotte That talk describes a solution done for an internal company application. This open ended /query endpoint shouldn't be public. There's another talk about "datomic superpowers" where they sanitize the query and add constraints (can't remember if in a database function or by appending :where clauses) according to user roles: https://www.youtube.com/watch?v=7lm3K8zVOdY
Should lookup refs in transactions work fine? - I thought they would, but I do get :db.error/not-an-entity Unable to resolve entity: ...
.
[...
{:db/id #db/id[:db.part/user]
:some/tag "whatever"}
{:db/id #db/id[:db.part/user]
:ref-to-some [:some/tag "whatever"]}
...
]
:some/tag
is a unique string (unique-value or unique-identity)in map txes, you must wrap with {:db/id lr}
so {:db/id [:some/tag "whatever"]}
? What if I want to put it in a different partition?
:ref-to-some {:db/id [:some/tag "whatever"]}
aah, sorry.
at this point, it's already in a partition
yeah, right. get it, thx.
... or not. It doesn't seem to work: still same error.
java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: [:some/tag "whatever"] in datom [#db/id[:db.part/user -1] :ref-to-some [:some/tag "whatever"]]
So, no lookup refs in transactions. Switching back to #db/id[db.part/user -1]
and stuff. Too bad.
@kurt-yagram lookup refs can only find entities that are already in storage. you need to use temp ids to refer to temp ids
allright, thanks!
If I query a db, can I return a default value if a many-cardinality attribute doesn't contain any value? (something like get-else
, but for many-cardinality)
@kurt-yagram You could probably write something using missing?
and ground
to do so,
aha, missing
seems to be something...
this does the trick, there may be no attrs
in :some/attr
:
[(missing? $ ?t :some/attr) ?no-attr]
(or-join [?no-tag]
[?t :some/attr ?attrs]
[(when ?no-attr []) ?attrs])]
or not... it's not right.
I figured out a way to do this in the past at one point.
I think it was a missing
and a ground
clause both inside an or
@kenny thanks for the feedback. That is in-line with what I was planning. Was hoping there was already some published example, but not sure how generic vs. application-specific the result will be.
Datomic 0.9.5404 is now available https://groups.google.com/d/topic/datomic/JKbyd8VFYm8/discussion
@yonatanel I'm not sure that's true. The speaker at one point refers to the web service layer handle edge concerns to protect from the "Scary internet". In any case if you support authentication and authorization, and sufficiently sanitize the input, I could see doing the same thing for an internet facing application.
hihi. can I ask maybe a stupid question, however I am new to data structures and algorithms
so I was trying to google that out, but still: is datomic um.. indexes sort of persistent data structures, right?
(the guide says that datomic stores segments, not individual datoms in the tree. so this means those have to be periodically rebuilt and written anew somewhere on the disk)
@leov yes and no. It does store segments, and the indexes are periodically rewritten (see http://docs.datomic.com/capacity.html#indexing for the performance impact), but the segments themselves are immutable.
@leov persistent datastructures means “when I ‘update’ the structure, the old one is untouched, and I have a new structure representing the change’. kind of like a git fork
if you’re interested in implementation details, etc. Rich’s Writing Datomic in Clojure talk is probably the best resource: https://www.infoq.com/presentations/Datomic (though note that some details may have changed since then of course).