This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-03
Channels
- # aws (5)
- # beginners (67)
- # boot (30)
- # cider (55)
- # clara (7)
- # cljs-dev (6)
- # cljsjs (6)
- # cljsrn (1)
- # clojure (136)
- # clojure-brasil (2)
- # clojure-dusseldorf (14)
- # clojure-finland (9)
- # clojure-italy (49)
- # clojure-nl (1)
- # clojure-romania (6)
- # clojure-russia (4)
- # clojure-uk (16)
- # clojurescript (136)
- # core-async (1)
- # cursive (21)
- # datomic (64)
- # fulcro (26)
- # hoplon (25)
- # jobs-discuss (53)
- # keechma (3)
- # leiningen (6)
- # luminus (11)
- # lumo (2)
- # off-topic (351)
- # om (1)
- # onyx (11)
- # parinfer (32)
- # portkey (9)
- # re-frame (45)
- # reagent (38)
- # shadow-cljs (60)
- # specter (9)
- # vim (8)
- # yada (22)
hey everyone, I am new to clojure and datomic, and I have a simple questions does anyone know why this query:
(d/q '[:find ?id ?type ?urgent
:where
[?e :job/id ?id]
[?e :job/type ?type]
[?e :job/urgent ?urgent]] (get-db))
returns the following: #object[java.util.HashSet 0x4362c471 [[690de6bc-163c-4345-bf6f-25dd0c58e864 bills-questions false]]]
but all I want is [690de6bc-163c-4345-bf6f-25dd0c58e864 bills-questions false]
I can get the answer I want but using first
, but why is datomic retuning such a weird output, is there a way to get just what I actually want?See here: https://docs.datomic.com/on-prem/query.html#find-specifications
Basically with :find ?a ?b ?c :where ...
you’ll get a set of tuples. This makes sense if you consider that there could be more than one result from your query. If you know there will only be a single result you can use :find [?a ?b ?c] :where ...
instead
I have an entity with two reference fields on it. Is there a way to write a datomic query that, given an ID, returns the entity if the id is contained in either ref field? Like an or
for a query?
does anyone know how I can save a vector on datomic and retrieve it as if it was any other literal value?
@brnbraga95 you can't. store values unsorted with cardinality many. If you need ordering, store refs and add a sort attribute to the entities
if I use cardinality many, then how can I at least retrieve all the values at once and store into an array? assuming lets say, I have an array of favorite foods.
the entity or pull APIs would be good for that. e.g. (-> (d/entity (d/db conn) my-ref) :myentity/favorite-foods)
problem is that I believe I am not using the entity-id
so it just creates a new entity.
(d/transact (get-connection) [
{:job/id (first job)
:job/type ((second job) "type")
:job/urgent ((second job) "urgent")
:job/timestamp (bigint (System/currentTimeMillis))
:job/requester agent-id
:job/status "doing"}
])
Technically you could also store vectors as edn strings, but I wouldn't recommend it
@marshall The password with datomic free works beautifully as soon as I update the peer too. Maybe add this to the page. Feeling stupid after having run in circles for a couple of hours 😉
Is datomic a good fit for a chat app? I have more reads than writes, but if I get too much messages/second to persist and only one transactor at a time can handle writes, I might end up in a situation where the transactor run out of memory. Even in HA mode, an other transactor would replace the dead one, but it would end up in the same situation. Is this true ?
can I assume that a Client that loses its connection to the datomic system will automatically be able to use the connection once it's again available? or is there some logic required to again setup the connection?
peers reconnect automatically (actually it can be sometimes hard to detect--only transactions will fail). I don't know about clients
we're getting ActiveMQNotConnectedException
trying to connect to datomic on remote host, our url string looks like this: "datomic:<sql://datomic?jdbc:postgresql://1.2.3.4:5432/datomic?user=alice&password=secret>
are we mangling the ports somehow? we can connect to 5432 (postgres) but 8998 (peer) and the peer api are not connecting
the same ports all work fine when the transactor/peer/postgres are all on localhost
the ArtemisMQ error indicates your peer is connecting to storage but not to the transactor
can HOST be localhost? our file reads protocol=sql host=localhost port=4334
(we're running the transactor and peer on the same box)
no, just a short stack trace with create-session-factory
using peer only
ok transactor is running with datomic:sql://<DB-NAME>?jdbc:<postgresql://localhost:5432/datomic?user=alice&password=secret>
peer is serving datomic:<sql://datomic?jdbc:postgresql://localhost:5432/datomic?user=alice&password=secret>
that is the peer server INFO log message
transactor and peer are both running on the same remote machine, and we're attempting to launch the PEER client from a laptop REPL
if you’re trying to connect a peer (i.e. using datomic.api) from another system, you need to add an alt-host value to your transactor properties file that is the remotely-resolvable address of the transactor instance
our clojure repl has [datomic.api] from the datomic-pro, and we have the following uri: datomic:<sql://datomic?jdbc:postgresql://1.2.3.4:5432/datomic?user=alice=password=secret>
that ^ won’t work unless you’ve added 1.2.3.4 as the host (or alt-host) in txor properties file
where 1.2.3.4 is the remote IP address for the box with transactor+peer running, and alice and secret are the params in the datomic.properties file
it’s almost always better to use the actual system address (as resolvable from outside) for the value of host in your properties file
ah! that worked! we seemed to have made the classic 127.0.0.1->0.0.0.0 server error
+1 by the way on not needing to start the extra peer server
we intend to run 4 peer clients and no cloud api clients for the moment
does anyone know how I can every value from a certain field that has cardinality many?
@christian767 told me to use this (-> (d/entity (d/db conn) my-ref) :myentity/favorite-foods)
but I did not quite understood this query