This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws-lambda (7)
- # beginners (80)
- # boot (134)
- # cider (11)
- # cljs-dev (5)
- # cljsjs (3)
- # cljsrn (19)
- # clojure (144)
- # clojure-austin (2)
- # clojure-berlin (3)
- # clojure-greece (6)
- # clojure-italy (3)
- # clojure-russia (95)
- # clojure-spec (57)
- # clojure-uk (120)
- # clojure-za (2)
- # clojurescript (71)
- # component (1)
- # css (1)
- # cursive (22)
- # datascript (2)
- # datomic (101)
- # dirac (9)
- # docker (3)
- # emacs (10)
- # events (2)
- # immutant (3)
- # leiningen (2)
- # om (63)
- # om-next (1)
- # onyx (6)
- # pedestal (55)
- # portland-or (3)
- # protorepl (2)
- # re-frame (30)
- # reagent (10)
- # ring-swagger (1)
- # rum (31)
- # spacemacs (5)
- # specter (9)
- # untangled (90)
- # vim (46)
- # yada (2)
can i restore to an existing database? I've been trying to seed my database for my clients and running and re-running my import scripts, I get the error "The name 'restore1' is already in use by a different database"... The problem is it takes over 30 mins to build and deploy my code, which i need to do when i want to create a new database
total beginner's question: what's the difference between an ident and a lookup ref ?
@sova ident is usually a keyword you use instead of an attribute ID. Such as
A lookup ref is used to identify a specific entity. You can lookup an entity using
:db/id 124312345123254 (using the entity ID), or with a lookup ref such as
:db/id [:user/email "[email protected]"]. For this to work you need to have the attribute (i.e.
:user/email) defined as
:db/unique :db.unique/identity in your schema.
on top of that i would add that lookup ref throws when no entity is found. if one does
:db/id 124312345123254 that assumes that id got queried before, and in case it is not in db you get back nil. so you can check aot instead of catching exception...
Where can i find more info on paginating using (d/datoms) ? I read you can return lazy sequences this way.
n.m looked at mbrainz sample... this is really an underdocumented way to assist with pagination. very nice
here's an example of something i just put together... i import all my entities to elasticsearch
But we do a simple query for for example only the db/id and the company/name for us
just realizing i shouhld be calling _db and not my function that returns a new db in the function.
Aha that seems like a problem, if you have them in elasticsearch why not serve them from elasticsearch?
because it needs to pull the whole collection... with 2M records (and enough RAM) it would take like a minute per page
Ah ok, we will also have to reach out to ES in the future, but currently our collections are not bigger then 10.000 luckily..
Thank you for the example seek-datoms seems like something I might need in the future
@jdkealy if you scroll up a bit there was a lengthy discussion on pagination the other day
Perhaps a dumb question: trying to simply determine if two entity references refer to the same entity in a datomic query. This is non-working code shows what I’m trying to do:
Of course I get:
(defn same-person? [db p1 p2] (d/q '[:find ?p2 . :in $ ?p1 ?p2 :where (= ?p1 ?p2)] db p1 p2))
IllegalArgumentException Cannot resolve key: =
.. and this the function can be called like
(same-person? ddb [:person/slug "romeo-montague"] [:person/email "
@bballantine be aware that if you do not know ?p1 and ?p2 are both entity ids you may be lead astray
@bballantine If necessary, use datomic.api/entid to normalize, inside or outside of the query
@favila yeah.. been messing with that.. seems a bit clunky, but this works currently:
(defn same-person? [db p1 p2] (d/q '[:find ?p . :in $ ?p1 ?p2 :where [(datomic.api/entid $ ?p1) ?p1-id] [(datomic.api/entid $ ?p2) ?p2-id] [?p1-id :person/slug ?p] [?p2-id :person/slug ?p]] db p1 p2))
Yeah.. right, so this works:
(defn same-person? [db p1 p2] (d/q '[:find ?p . :in $ ?p1 ?p2 :where [?p1 :person/slug ?p] [?p2 :person/slug ?p]] db p1 p2))
clojure idiom is functions that end in ? return boolean, so you may want to coerce at the end, but that's besides the point
Actually this works and seems more.. direct:
(defn same-person? [db p1 p2] (d/q '[:find ?p1-id . :in $ ?p1 ?p2 :where [(datomic.api/entid $ ?p1) ?p1-id] [(datomic.api/entid $ ?p2) ?p2-id] [(= ?p1-id ?p2-id)]] db p1 p2))
I guess to answer your other question, it could be generalized (if it was stand-alone) to be called
[?p1][?p2][(= ?p1 ?p2)] may work as such a rule, assuming datalog normalizes idents and lookups to entids
I know it will understand them in the E or A slot (not the V slot ever!) of datalog match clauses
but = treats its arguments as values not relations, so not sure what the actual values will be
@favila - thanks again. Was just experimenting with the last suggestion. Unless I get the entity-ids out and compare them, the entity refs don’t pass the equivalency check. As you said, it seems
= is just treating the entity refs as values. i.e. [:person/slug "romeo-montague"] is not equal to [:person/email “<mailto:[email protected]|[email protected]>"]
A good habit is to call d/entid on inputs to queries or at the top of a query on its entity-id-typed arguments in
:in that the query will use
In the end, this Imma go with something like.. Actually might turn it into a rule.
(defn same-entity? [db p1 p2] (some? (d/q '[:find ?p1-id . :in $ ?p1 ?p2 :where [(datomic.api/entid $ ?p1) ?p1-id] [(datomic.api/entid $ ?p2) ?p2-id] [(= ?p1-id ?p2-id)]] db p1 p2)))
e.g. of a gotcha where this matters
[?e :person/friend ?p1], if ?p1 is not an entid it will never match
in Datomic is it possible to get the "max 9 " of a db? Instead of just the absolute max?
... is there something really wrong with my Pull syntax?
(defn get-blurb-info [bid] (d/q '[:find [(pull (d/db conn) [*] bid) ...] :in $ :where [?bid :blurb/title ?title] [?bid :blurb/link ?link] [?bid :author/email ?author] [?bid :blurb/content ?content]] (d/db conn)))
I'm just experimenting trying to track down what I've got mixed up... Ideally I'd just like to get all the results possible in this case (without supplying an entity ID)
Hmm. Okay.. but removing that still leaves (pull [*] bid) which is an "invalid-pull" ...