This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-25
Channels
- # aleph (15)
- # beginners (65)
- # boot (46)
- # chestnut (3)
- # cider (1)
- # clara (11)
- # cljs-dev (5)
- # cljsjs (4)
- # cljsrn (13)
- # clojure (180)
- # clojure-dev (2)
- # clojure-italy (10)
- # clojure-russia (62)
- # clojure-spec (6)
- # clojure-uk (85)
- # clojurescript (45)
- # community-development (11)
- # crypto (3)
- # cursive (10)
- # datomic (94)
- # defnpodcast (2)
- # fulcro (4)
- # heroku (1)
- # hoplon (4)
- # jobs (3)
- # juxt (10)
- # leiningen (1)
- # luminus (4)
- # mount (13)
- # music (1)
- # off-topic (10)
- # onyx (2)
- # portkey (15)
- # proton (2)
- # re-frame (16)
- # reagent (10)
- # shadow-cljs (194)
- # spacemacs (2)
- # specter (2)
I need to generate some invitation codes... Maybe datomic has some built-in functionality for this?
datomic doesn't have any built in functions to generate data transactor side that I can think of
@dimovich generate it on the peer? is there any particular reason you want Datomic to do it for you?
@dominicm a sufficiently long random code should guarantee uniqueness to a high enough degree of certainty, no?
@hmaurer sufficiently high is relative I suppose. Presuming that you want the token to be of a short length due to external constraints, it becomes more complicated.
what you could also do is have a :db.unique/value
constraint on the invitation code, generate it on the peer, and retry if the transaction fail because of a uniqueness exception
Soliciting Help: I’ve got a peer that sets up the schema for a database, and then successfully transacts several additional entities. A client using the client API then connects and tries to query the DB for those entities -but without seeing them. Most suspicious, the client API reports that it can’t even resolve the new schema entity and reports :t 1002
…which to me says the client API does not seen any of the peer’s transactions.
Looks like a problem with the peer server communication. If I start a transaction from a client, the transaction is sent off, and the peer server shows it in its logs, but the response from the transactor never appears in the peer server’s logs and the client never gets an answer and eventually times out.
@dimovich if the data has to be generated on the txtor, you can do this in a txtor function
I have a datalog question;
I have some datalog that returns tuples; I only want a sample of 10 items; is the any way I can use something like
(d/q '[:find (rand 10 [?val1 ?val2])
@benha You could try coercing the result to a vector, then use the sample
aggregation function
however, the whole result is realized in memory all the time anyway, even with sample
, so there's no benefit to doing it in the query
how would I coerce results to a vector ?
naive (d/q '[:find (sample 10 [?val1 ?val2])
gets me
java.lang.IllegalArgumentException: Argument [?val1 ?val2] in :find is not a variable
A few times know I’ve had a datomic entity that needs to serialized in order to include in a web response. I find that I’ve been doing a [:*]
pull in those cases, but was wondering if there was a more succinct way to go from datomic entity to hash-map. Any insight?
Only feels a little verbose because I’ve got to have the db available and in our controllers that’s not always the case
But it’s def not too bad, just wondering if there was something sort of like touch
that gives back a hash map
We’ve kind of got an mvc-like namespace setup where datomic functions interact with the db, then give back the results to the controller. The controller then decides what the web response body should look like. We don’t typically have the db readily available in those controller namespaces
Usually just some ring related utils and maybe some spec validation stuff
Typically an entity or collection of entities
Oh sweet
Did not know that
Cool, so that would make pulling on the entity much simpler
Thanks
Yeah didn’t know that
I can see why confusing to you armed with that knowledge
Yeah it was more like I want to turn a lazy datomic entity into a hash-map
Does that work? I feel like I tried that and still got some serialization exception
I could be wrong though — it was a while back
Actually remember now, it works as long as there are no references to other entities
Right
Yeah, I feel like pull is really the right thing to do, just wanted to see if there was something else
Yeah agree
About pull-api: how to deal with enums? Example: :user/tags
is a ref-to-many. I usualy want to send {:user/tags [:tag/1]}
to frontend, not {:user/tags[{:db/id 3123}]}
.
I made some code that replace all {:db/id 1321}
that has a ident to this ident. But not sure if there is a better way to deal...
{:user/tags [{:db/ident :tag/1}]}
is better then {:user/tags [{:db/id 123456}]}
but still not {:user/tags [:tag/1]}
...
But I reached the case: I have a entitie that is a enum but contains other attributes. Then sometimes I want to see all attr, others I want to use as enum... Once I transform with specter on a default interceptor...
Hi all, does anyone know where the :db/fn definition for the :db/add and :db/retract tx functions live? I can't seem to find it in the extent of the respective entities nor in the :db.part/db entity.
They could still expand to the actual datom but it does make more sense that the transact function (peer or transactor side) would take care of this.
If I want to reconstruct a database with all the old transactions intact, can I do that? If the old database consists of 1000 transactions, do I need to perform 1000 transactions to the empty database too, or is it another way of doing it? Some of the facts need to be filtered out also in the target database so it’s not just a simple dump/backup.
You need 1000 transactions, in the same order. You can reconstruct the old transaction times by setting :db/txInstant on each transaction; but you cannot alter transaction times after transacting
(defn add-to-tx-data
[db tx-data]
(let [{:keys [db-after db-before tempids tx-data]} (d/with db tx-data)
ids-after (d/q MY-QUERY db-before db-after tx-data)]
(into tx-data
(for [id ids-after]
[:db/add (resolve-id->tempid tempids id) :foo/bar true]))))
Existi some way to do resolve-id->tempid
? It shoud look to tempids and if there is a tempid that was "resolved" into this id in transaction, returns this tempid, else return the id.I can't think of a way to do it that doesn't involve being careful about what external ids each entity has