This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-10
Channels
- # aleph (3)
- # architecture (3)
- # bangalore-clj (5)
- # beginners (75)
- # boot (75)
- # cider (2)
- # cljs-dev (48)
- # cljsjs (3)
- # cljsrn (17)
- # clojure (125)
- # clojure-belgium (1)
- # clojure-boston (1)
- # clojure-italy (20)
- # clojure-losangeles (2)
- # clojure-spec (73)
- # clojure-uk (34)
- # clojurescript (127)
- # cursive (8)
- # data-science (5)
- # datascript (128)
- # datomic (5)
- # emacs (4)
- # events (3)
- # fulcro (1)
- # jobs (1)
- # jobs-discuss (4)
- # jobs-rus (9)
- # keechma (79)
- # lein-figwheel (2)
- # leiningen (2)
- # lumo (31)
- # om (1)
- # parinfer (61)
- # pedestal (1)
- # planck (1)
- # portkey (31)
- # re-frame (34)
- # reagent (53)
- # ring (3)
- # ring-swagger (13)
- # rum (1)
- # spacemacs (14)
- # testing (1)
- # yada (2)
@tonsky so it looks like when i put datoms into a db that have a tx, then i do a new transaction, it doesn't force the new datoms to have a higher tx than the tx that i put in... is that right?
i expected db-with
to internally update the "next tx" value to something higher than the max value of the datoms that it puts in the db
e.g. i have a datom in the db like [1501664966212 :project/title "fooodoodo" 536870923]
:max-tx
of the db is 536870913
@thedavidmeister you can’t put datoms into DB with specific tx value, at least not officially
oh... hmmm
how do i share datoms between users?
that was more of a practical question than "official" question
if i'm trying to move datoms in and out of some dbs
uh, well a db in one browser and a db in another
like, two users collaborating, so if you put datoms in one it can be shared to the other
i just thought tx would be a convenient way to deal with conflicts
just use the newest tx, that kind of thing
if two users make simultaneous edit to their corresponding db the tx will be the same for both the the content of it will be different
yeah, there is a central db that would need to deal with that
basically use timestamp as a tie breaker
no, there’s no convenient way to deal with conflicts. Not just in datascript, but in general
hmmm, well i'm actually not even at that point yet
all i'm at is putting datoms into a db
then pulling them back out
i'm not sure how to do that
i'm putting datoms into a db on the server
and then pulling them back out
how can i model attributes/entities for the datoms themselves?
isn't that circular logic?
actually i'm not even doing that yet
i'm just putting datoms in the db
and pulling them out
but it doesn't work
well ok, when i pull the datoms out, i pull out the highest tx
so as not to send the history of all datoms over the wire every time
so the problem is that now when it puts "new" datoms into the db
they have lower tx than something already in the db
so it looks like you cannot update the database, changes are "lost" when you reload the page
even though the datoms are in the db, just with lower tx
the problem must in somewhere else, because you can’t put datoms into DB and force any specific TX value on them. DB will assign it automatically. You have no control over it
i mean yeah i thought they should
i get e, a, v, tx and added out of the server and turn it into datoms and add it to local db
uh, pretty sure i just put a list of datoms in db-with
hang on
(d/datom
(:e r)
(read-string.core/read-string (:a r))
(read-string.core/read-string (:v r))
(:tx r)
(:added r)))
(swap! conn #(d/db-with % [d]))
why can't i do that?
hah, i really like it, so thanks 🙂
anyways, adding datoms doesn’t have any magic properties and doesn’t magically make your system distributed
the problem you were concerned with — getting right tx numbers — also has nothing to do with what you see in a database
you see everything you’ve added to it. No matter what TX number is and in which order it was populated
so you can add smth with tx 0 then smth with tx 10 then smth with tx 5 and you’ll see data from the last tx. Last in actual time, not with the highest tx number
oh, so you see tx 5?
wouldn't you just drop it?
as datascript doesn't keep history
ok but let's say i use timestamps instead of tx
and i just leave tx be tx
how do i get timestamps on a datom?
well i put timestamps on datoms in the db
i do that now
but then comparing incoming timestamps with data already in datascript
not sure how to do that
was thinking of putting metadata on the datom or something, but i don't know that it gets preserved through transact!
yeah that's that i thought
the datom is just a temporary object outside the db right?
so metadata would be lost somewhere along the line
probably
if i use transact! would it update the max-tx?
but i can't set the tx
right?
also, i'm using swap!
to avoid triggering listeners
because my listeners send data
i don't want to send what i'm receiving
i think i need some extra accounting in between datascript and the server
@tonsky so, I should not really use any tx-meta
(as in (defn transact! [conn tx-data tx-meta] ...
) values I put in, during server synchronization?
to paraphrase: anything in tx-meta should be used only by the same process, which put tx-meta into db? and tx-meta should not survive transit de/serialization?
that's a bit different to what i'm looking at i think
you're looking at the tx data itself, not the tx id on the datoms right?