Fork me on GitHub
#datomic
<
2017-12-19
>
Kevin Blanton03:12:16

Good evening. We are using the with to allow users to perform some speculative transactions so that they can see how their changes affect other things before deciding whether or not to actually commit the changes. We have captured db-after and tempids from the results of the with statement. We can use the resolve-tempid function to determine the id that was assigned during the with, but has anyone found a method to go the other direction? Meaning… we would like to map through the tempids returned and convert them back to the original temp-id that was sent in the tx for the with.

favila06:12:15

:tempids is just a map. Resolve-tempid is a convenience to construct numeric tempids (the negative numbers) from the tempid records created by d/tempid. You can use d/part, d/tx->t, d/ident and some bit twiddling to get an equivalent tempid record from a negative long

favila06:12:28

You can use d/entid-at and d/entid to make the negative long from the tempid record yourself

Kevin Blanton13:12:12

Thanks @U09R86PA4. I will give this a try.

atticmaverick19:12:39

im going through the peer getting started guide http://docs.datomic.com/peer-getting-started.html and I keep getting ":db.error/entity-missing-db-id Missing :db/id" when attempting to transact the schema. Im confused as to why this fails.

favila19:12:20

Are you sure you are transacting (transact conn [{:db/id ...}]) not (transact conn {:db/id ...})?

atticmaverick19:12:53

yes i am sure. I am providing a vector of maps. I've copied and pasted from the site to make sure it wasnt me. I am not using the mem storage protocol and have moved to the local dev setup and am trying to run through some of the examples again. Im not sure if that has something to do with it

favila19:12:37

paste the expression you are running

favila19:12:50

also, verify what version of datomic you are using

favila19:12:05

(being able to transact schema entities without :db/id is a more recent ability)

atticmaverick19:12:01

datomic-pro-0.9.565

atticmaverick19:12:25

@(d/transact conn [{:db/ident :movie/title
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "The title of the movie"}])

favila19:12:35

and this throws the error?

favila19:12:45

does it throw it when you use a mem db?

atticmaverick20:12:30

I didnt have any problems with mem

favila20:12:28

is your transactor definitely the same up-to-date version?

atticmaverick20:12:11

I suppose but I dont know for sure. I downloaded the zip and I am running everything from the ./datomic-extracted/bin directory

marshall21:12:11

user=> (require '[datomic.api :as d])
nil
user=> (def db-uri "datomic:)
#'user/db-uri
user=> (d/create-database db-uri)
true
user=> (def conn (d/connect db-uri))
#'user/conn
(def movie-schema [{:db/ident :movie/title
                           :db/valueType :db.type/string
                           :db/cardinality :db.cardinality/one
                           :db/doc "The title of the movie"}

                          {:db/ident :movie/genre
                           :db/valueType :db.type/string
                           :db/cardinality :db.cardinality/one
                           :db/doc "The genre of the movie"}

                          {:db/ident :movie/release-year
                           :db/valueType :db.type/long
                           :db/cardinality :db.cardinality/one
                           :db/doc "The year the movie was released in theaters"}])
#'user/movie-schema
user=> @(d/transact conn movie-schema)
{:db-before datomic.db.Db@fd9c54cd, :db-after datomic.db.Db@c1b25f3b, :tx-data [#datom[13194139534312 50 #inst "2017-12-19T21:03:39.346-00:00" 13194139534312 true] #datom[63 10 :movie/title 13194139534312 true] #datom[63 40 23 13194139534312 true] #datom[63 41 35 13194139534312 true] #datom[63 62 "The title of the movie" 13194139534312 true] #datom[64 10 :movie/genre 13194139534312 true] #datom[64 40 23 13194139534312 true] #datom[64 41 35 13194139534312 true] #datom[64 62 "The genre of the movie" 13194139534312 true] #datom[65 10 :movie/release-year 13194139534312 true] #datom[65 40 22 13194139534312 true] #datom[65 41 35 13194139534312 true] #datom[65 62 "The year the movie was released in theaters" 13194139534312 true] #datom[0 13 65 13194139534312 true] #datom[0 13 64 13194139534312 true] #datom[0 13 63 13194139534312 true]], :tempids {-9223301668109598143 63, -9223301668109598142 64, -9223301668109598141 65}}
user=>

marshall21:12:29

i just tried from the bin/repl on 0.9.5656

atticmaverick21:12:06

@U05120CBV I tried that and I still get the ":db.error/entity-missing-db-id Missing :db/id" error. Maybe I'm not running the transactor and peer server correctly?

bin/run -m datomic.peer-server -h localhost -p 8998 -a myaccesskey,mysecret -d test,datomic:
bin/transactor ./dev-transactor-template.properties

atticmaverick21:12:50

the only thing i added to the template is the license

favila21:12:20

wait I thought you were using the "peer getting started" guide?

favila21:12:32

why are you running a datomic peer server?

favila21:12:00

peer server is for the client api

marshall21:12:45

@U09R86PA4 is correct. no peer server required for using the peer itself

marshall21:12:04

have you started your transactor?

atticmaverick22:12:09

@U05120CBV i have started the transactor. even the basic

@(d/transact conn [{:db/doc "Hello world"}])
gives me
IllegalArgumentExceptionInfo :db.error/entity-missing-db-id Missing :db/id  datomic.error/arg (error.clj:57)

marshall22:12:24

what version of datomic ?

atticmaverick22:12:36

datomic-pro-0.9.5656

marshall22:12:19

can you send me your log file? it’s in the log directory under the datomic distro

atticmaverick22:12:15

sent the email

marshall22:12:27

are you running the peer from a repl started with bin/repl in the same dir?

marshall22:12:03

and can I see your ‘require’ line in the repl please

atticmaverick22:12:34

this is in my project outside of the directory not using the bin/repl

atticmaverick23:12:00

(require '[datomic.api :as d])

atticmaverick23:12:17

it's pretty clear im missing something fundamental so i'm going to start over. I have an application written in clojure with a postgres db. I wanted to learn datomic so I thought it would be cool to replace postgres with datomic in this simple app. So a new question (starting from scratch): I want to have a local datomic database (strictly development) on my machine to read and write from within my clojure code. Is there a link or tutorial that would help me achieve this? What components of datomic would I need to run? And what would I use to make queries and transactions to datomic from clojure?

marshall01:12:50

in your project what version of the datomic peer library are you using

marshall01:12:10

i.e. in your project.clj or your pom.xml or whatever you’re using

marshall01:12:48

you’re using the right tutorial/etc. i now strongly suspect you’ve got an old version of the peer library in your project