Transacting API for Datomic
Certainly a dumb question, but hopefully should clear things up.
I am following along https://docs.datomic.com/on-prem/getting-started/transact-schema.html, and the step to transact the schema, in this tutorial, is
user=> (d/transact conn {:tx-data movie-schema})
However, when I try this, I get
ClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.util.List datomic.api/transact
Instead, when I just do
(d/transact conn schema)
it works for me. Is the tutorial missing some subtlety here? Am I missing something? (the only difference is that I'm using the Free version instead of the Starter Pro version).
Edit: the initial version of this post mentioned the schema, but this is generally true for just adding new facts too (i.e. using {:tx-data foo}
doesn't work, but just using foo
does).
clojure datomic
add a comment |
Certainly a dumb question, but hopefully should clear things up.
I am following along https://docs.datomic.com/on-prem/getting-started/transact-schema.html, and the step to transact the schema, in this tutorial, is
user=> (d/transact conn {:tx-data movie-schema})
However, when I try this, I get
ClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.util.List datomic.api/transact
Instead, when I just do
(d/transact conn schema)
it works for me. Is the tutorial missing some subtlety here? Am I missing something? (the only difference is that I'm using the Free version instead of the Starter Pro version).
Edit: the initial version of this post mentioned the schema, but this is generally true for just adding new facts too (i.e. using {:tx-data foo}
doesn't work, but just using foo
does).
clojure datomic
I've noticed another inconsistency: while my toy example now works (yay), the result is a hash-set, while the result in the tutorial is a vector; not sure what to make of this.
– agam
Nov 4 '18 at 8:51
add a comment |
Certainly a dumb question, but hopefully should clear things up.
I am following along https://docs.datomic.com/on-prem/getting-started/transact-schema.html, and the step to transact the schema, in this tutorial, is
user=> (d/transact conn {:tx-data movie-schema})
However, when I try this, I get
ClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.util.List datomic.api/transact
Instead, when I just do
(d/transact conn schema)
it works for me. Is the tutorial missing some subtlety here? Am I missing something? (the only difference is that I'm using the Free version instead of the Starter Pro version).
Edit: the initial version of this post mentioned the schema, but this is generally true for just adding new facts too (i.e. using {:tx-data foo}
doesn't work, but just using foo
does).
clojure datomic
Certainly a dumb question, but hopefully should clear things up.
I am following along https://docs.datomic.com/on-prem/getting-started/transact-schema.html, and the step to transact the schema, in this tutorial, is
user=> (d/transact conn {:tx-data movie-schema})
However, when I try this, I get
ClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.util.List datomic.api/transact
Instead, when I just do
(d/transact conn schema)
it works for me. Is the tutorial missing some subtlety here? Am I missing something? (the only difference is that I'm using the Free version instead of the Starter Pro version).
Edit: the initial version of this post mentioned the schema, but this is generally true for just adding new facts too (i.e. using {:tx-data foo}
doesn't work, but just using foo
does).
clojure datomic
clojure datomic
edited Nov 4 '18 at 8:47
agam
asked Nov 4 '18 at 8:37
agamagam
1,40451623
1,40451623
I've noticed another inconsistency: while my toy example now works (yay), the result is a hash-set, while the result in the tutorial is a vector; not sure what to make of this.
– agam
Nov 4 '18 at 8:51
add a comment |
I've noticed another inconsistency: while my toy example now works (yay), the result is a hash-set, while the result in the tutorial is a vector; not sure what to make of this.
– agam
Nov 4 '18 at 8:51
I've noticed another inconsistency: while my toy example now works (yay), the result is a hash-set, while the result in the tutorial is a vector; not sure what to make of this.
– agam
Nov 4 '18 at 8:51
I've noticed another inconsistency: while my toy example now works (yay), the result is a hash-set, while the result in the tutorial is a vector; not sure what to make of this.
– agam
Nov 4 '18 at 8:51
add a comment |
2 Answers
2
active
oldest
votes
I think the cause of your problem here is an inconsistency between the Peer API (in which transact
accepts a list) and the Client API (in which transact
accepts a map containing a :tx-data
key). I suspect you tried to run your REPL commands in the REPL of a Peer process, whereas the tutorial you linked to expects you to run commands in the REPL of a Client process.
Why the inconsistency between Peers and Clients? Not being part of the Datomic team, I can only speculate:
- The Peer API was designed before the Client API historically, at which time the 'transaction requests as lists' format was sufficient
- When the Client API was designed, because of the more expensive nature of calling
d/transact
(I believe it incurs an additional I/O roundtrip from client to server), the authors left room for additional data in transaction requests (e.g for templating), hence the more extensible map-based format.
That makes sense! I'm not sure why I ended up in the REPL of the "wrong" process, but this would explain the inconsistency I observed.
– agam
Nov 18 '18 at 19:14
add a comment |
You can see a working demo here: https://github.com/cloojure/tupelo-datomic
Just clone the repo and run the tests:
~/tupelo-datomic > lein test
lein test tst.tupelo-datomic._bootstrap
----------------------------------
Clojure 1.9.0 Java 10.0.1
----------------------------------
lein test tst.tupelo-datomic.bond
lein test tst.tupelo-datomic.bond-query
lein test tst.tupelo-datomic.core
lein test tst.tupelo-datomic.find
lein test tst.tupelo-datomic.functionality
lein test tst.tupelo-datomic.quick-start
:using-local
Ran 17 tests containing 110 assertions.
0 failures, 0 errors.
~/tupelo-datomic >
Regarding your specific question, I have only used :tx-data
as a field from the output of Datomic operations. I have never used it as a field from input data. It is possible that the docs you reference are incorrect or out of date.
Here is an example (note the parens instead of curly braces):
https://github.com/cloojure/tupelo-datomic/blob/master/src/tupelo_datomic/core.clj#L540
For more detail, you can see the native Datomic function call as the output of the wrapper function new-attribute
in the unit tests: https://github.com/cloojure/tupelo-datomic/blob/master/test/tst/tupelo_datomic/core.clj#L46
(let [result (td/new-attribute
:weapon/type :db.type/keyword
:db.unique/value :db.unique/identity :db.cardinality/one :db.cardinality/many
:db/index :db/fulltext :db/isComponent :db/noHistory)]
(is (s/validate datomic.db.DbId (:db/id result)))
(is (wild-match? {:db/id :*
:db/ident :weapon/type
:db/index true
:db/unique :db.unique/identity
:db/noHistory true
:db/cardinality :db.cardinality/many
:db/isComponent true
:db.install/_attribute :db.part/db
:db/fulltext true
:db/valueType :db.type/keyword}
result)))
Thanks, my (surprising?) conclusion is that everything works (and works well!) but the docs were out of date.
– agam
Nov 5 '18 at 19:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139065%2ftransacting-api-for-datomic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think the cause of your problem here is an inconsistency between the Peer API (in which transact
accepts a list) and the Client API (in which transact
accepts a map containing a :tx-data
key). I suspect you tried to run your REPL commands in the REPL of a Peer process, whereas the tutorial you linked to expects you to run commands in the REPL of a Client process.
Why the inconsistency between Peers and Clients? Not being part of the Datomic team, I can only speculate:
- The Peer API was designed before the Client API historically, at which time the 'transaction requests as lists' format was sufficient
- When the Client API was designed, because of the more expensive nature of calling
d/transact
(I believe it incurs an additional I/O roundtrip from client to server), the authors left room for additional data in transaction requests (e.g for templating), hence the more extensible map-based format.
That makes sense! I'm not sure why I ended up in the REPL of the "wrong" process, but this would explain the inconsistency I observed.
– agam
Nov 18 '18 at 19:14
add a comment |
I think the cause of your problem here is an inconsistency between the Peer API (in which transact
accepts a list) and the Client API (in which transact
accepts a map containing a :tx-data
key). I suspect you tried to run your REPL commands in the REPL of a Peer process, whereas the tutorial you linked to expects you to run commands in the REPL of a Client process.
Why the inconsistency between Peers and Clients? Not being part of the Datomic team, I can only speculate:
- The Peer API was designed before the Client API historically, at which time the 'transaction requests as lists' format was sufficient
- When the Client API was designed, because of the more expensive nature of calling
d/transact
(I believe it incurs an additional I/O roundtrip from client to server), the authors left room for additional data in transaction requests (e.g for templating), hence the more extensible map-based format.
That makes sense! I'm not sure why I ended up in the REPL of the "wrong" process, but this would explain the inconsistency I observed.
– agam
Nov 18 '18 at 19:14
add a comment |
I think the cause of your problem here is an inconsistency between the Peer API (in which transact
accepts a list) and the Client API (in which transact
accepts a map containing a :tx-data
key). I suspect you tried to run your REPL commands in the REPL of a Peer process, whereas the tutorial you linked to expects you to run commands in the REPL of a Client process.
Why the inconsistency between Peers and Clients? Not being part of the Datomic team, I can only speculate:
- The Peer API was designed before the Client API historically, at which time the 'transaction requests as lists' format was sufficient
- When the Client API was designed, because of the more expensive nature of calling
d/transact
(I believe it incurs an additional I/O roundtrip from client to server), the authors left room for additional data in transaction requests (e.g for templating), hence the more extensible map-based format.
I think the cause of your problem here is an inconsistency between the Peer API (in which transact
accepts a list) and the Client API (in which transact
accepts a map containing a :tx-data
key). I suspect you tried to run your REPL commands in the REPL of a Peer process, whereas the tutorial you linked to expects you to run commands in the REPL of a Client process.
Why the inconsistency between Peers and Clients? Not being part of the Datomic team, I can only speculate:
- The Peer API was designed before the Client API historically, at which time the 'transaction requests as lists' format was sufficient
- When the Client API was designed, because of the more expensive nature of calling
d/transact
(I believe it incurs an additional I/O roundtrip from client to server), the authors left room for additional data in transaction requests (e.g for templating), hence the more extensible map-based format.
answered Nov 18 '18 at 12:06
Valentin WaeselynckValentin Waeselynck
4,3231938
4,3231938
That makes sense! I'm not sure why I ended up in the REPL of the "wrong" process, but this would explain the inconsistency I observed.
– agam
Nov 18 '18 at 19:14
add a comment |
That makes sense! I'm not sure why I ended up in the REPL of the "wrong" process, but this would explain the inconsistency I observed.
– agam
Nov 18 '18 at 19:14
That makes sense! I'm not sure why I ended up in the REPL of the "wrong" process, but this would explain the inconsistency I observed.
– agam
Nov 18 '18 at 19:14
That makes sense! I'm not sure why I ended up in the REPL of the "wrong" process, but this would explain the inconsistency I observed.
– agam
Nov 18 '18 at 19:14
add a comment |
You can see a working demo here: https://github.com/cloojure/tupelo-datomic
Just clone the repo and run the tests:
~/tupelo-datomic > lein test
lein test tst.tupelo-datomic._bootstrap
----------------------------------
Clojure 1.9.0 Java 10.0.1
----------------------------------
lein test tst.tupelo-datomic.bond
lein test tst.tupelo-datomic.bond-query
lein test tst.tupelo-datomic.core
lein test tst.tupelo-datomic.find
lein test tst.tupelo-datomic.functionality
lein test tst.tupelo-datomic.quick-start
:using-local
Ran 17 tests containing 110 assertions.
0 failures, 0 errors.
~/tupelo-datomic >
Regarding your specific question, I have only used :tx-data
as a field from the output of Datomic operations. I have never used it as a field from input data. It is possible that the docs you reference are incorrect or out of date.
Here is an example (note the parens instead of curly braces):
https://github.com/cloojure/tupelo-datomic/blob/master/src/tupelo_datomic/core.clj#L540
For more detail, you can see the native Datomic function call as the output of the wrapper function new-attribute
in the unit tests: https://github.com/cloojure/tupelo-datomic/blob/master/test/tst/tupelo_datomic/core.clj#L46
(let [result (td/new-attribute
:weapon/type :db.type/keyword
:db.unique/value :db.unique/identity :db.cardinality/one :db.cardinality/many
:db/index :db/fulltext :db/isComponent :db/noHistory)]
(is (s/validate datomic.db.DbId (:db/id result)))
(is (wild-match? {:db/id :*
:db/ident :weapon/type
:db/index true
:db/unique :db.unique/identity
:db/noHistory true
:db/cardinality :db.cardinality/many
:db/isComponent true
:db.install/_attribute :db.part/db
:db/fulltext true
:db/valueType :db.type/keyword}
result)))
Thanks, my (surprising?) conclusion is that everything works (and works well!) but the docs were out of date.
– agam
Nov 5 '18 at 19:29
add a comment |
You can see a working demo here: https://github.com/cloojure/tupelo-datomic
Just clone the repo and run the tests:
~/tupelo-datomic > lein test
lein test tst.tupelo-datomic._bootstrap
----------------------------------
Clojure 1.9.0 Java 10.0.1
----------------------------------
lein test tst.tupelo-datomic.bond
lein test tst.tupelo-datomic.bond-query
lein test tst.tupelo-datomic.core
lein test tst.tupelo-datomic.find
lein test tst.tupelo-datomic.functionality
lein test tst.tupelo-datomic.quick-start
:using-local
Ran 17 tests containing 110 assertions.
0 failures, 0 errors.
~/tupelo-datomic >
Regarding your specific question, I have only used :tx-data
as a field from the output of Datomic operations. I have never used it as a field from input data. It is possible that the docs you reference are incorrect or out of date.
Here is an example (note the parens instead of curly braces):
https://github.com/cloojure/tupelo-datomic/blob/master/src/tupelo_datomic/core.clj#L540
For more detail, you can see the native Datomic function call as the output of the wrapper function new-attribute
in the unit tests: https://github.com/cloojure/tupelo-datomic/blob/master/test/tst/tupelo_datomic/core.clj#L46
(let [result (td/new-attribute
:weapon/type :db.type/keyword
:db.unique/value :db.unique/identity :db.cardinality/one :db.cardinality/many
:db/index :db/fulltext :db/isComponent :db/noHistory)]
(is (s/validate datomic.db.DbId (:db/id result)))
(is (wild-match? {:db/id :*
:db/ident :weapon/type
:db/index true
:db/unique :db.unique/identity
:db/noHistory true
:db/cardinality :db.cardinality/many
:db/isComponent true
:db.install/_attribute :db.part/db
:db/fulltext true
:db/valueType :db.type/keyword}
result)))
Thanks, my (surprising?) conclusion is that everything works (and works well!) but the docs were out of date.
– agam
Nov 5 '18 at 19:29
add a comment |
You can see a working demo here: https://github.com/cloojure/tupelo-datomic
Just clone the repo and run the tests:
~/tupelo-datomic > lein test
lein test tst.tupelo-datomic._bootstrap
----------------------------------
Clojure 1.9.0 Java 10.0.1
----------------------------------
lein test tst.tupelo-datomic.bond
lein test tst.tupelo-datomic.bond-query
lein test tst.tupelo-datomic.core
lein test tst.tupelo-datomic.find
lein test tst.tupelo-datomic.functionality
lein test tst.tupelo-datomic.quick-start
:using-local
Ran 17 tests containing 110 assertions.
0 failures, 0 errors.
~/tupelo-datomic >
Regarding your specific question, I have only used :tx-data
as a field from the output of Datomic operations. I have never used it as a field from input data. It is possible that the docs you reference are incorrect or out of date.
Here is an example (note the parens instead of curly braces):
https://github.com/cloojure/tupelo-datomic/blob/master/src/tupelo_datomic/core.clj#L540
For more detail, you can see the native Datomic function call as the output of the wrapper function new-attribute
in the unit tests: https://github.com/cloojure/tupelo-datomic/blob/master/test/tst/tupelo_datomic/core.clj#L46
(let [result (td/new-attribute
:weapon/type :db.type/keyword
:db.unique/value :db.unique/identity :db.cardinality/one :db.cardinality/many
:db/index :db/fulltext :db/isComponent :db/noHistory)]
(is (s/validate datomic.db.DbId (:db/id result)))
(is (wild-match? {:db/id :*
:db/ident :weapon/type
:db/index true
:db/unique :db.unique/identity
:db/noHistory true
:db/cardinality :db.cardinality/many
:db/isComponent true
:db.install/_attribute :db.part/db
:db/fulltext true
:db/valueType :db.type/keyword}
result)))
You can see a working demo here: https://github.com/cloojure/tupelo-datomic
Just clone the repo and run the tests:
~/tupelo-datomic > lein test
lein test tst.tupelo-datomic._bootstrap
----------------------------------
Clojure 1.9.0 Java 10.0.1
----------------------------------
lein test tst.tupelo-datomic.bond
lein test tst.tupelo-datomic.bond-query
lein test tst.tupelo-datomic.core
lein test tst.tupelo-datomic.find
lein test tst.tupelo-datomic.functionality
lein test tst.tupelo-datomic.quick-start
:using-local
Ran 17 tests containing 110 assertions.
0 failures, 0 errors.
~/tupelo-datomic >
Regarding your specific question, I have only used :tx-data
as a field from the output of Datomic operations. I have never used it as a field from input data. It is possible that the docs you reference are incorrect or out of date.
Here is an example (note the parens instead of curly braces):
https://github.com/cloojure/tupelo-datomic/blob/master/src/tupelo_datomic/core.clj#L540
For more detail, you can see the native Datomic function call as the output of the wrapper function new-attribute
in the unit tests: https://github.com/cloojure/tupelo-datomic/blob/master/test/tst/tupelo_datomic/core.clj#L46
(let [result (td/new-attribute
:weapon/type :db.type/keyword
:db.unique/value :db.unique/identity :db.cardinality/one :db.cardinality/many
:db/index :db/fulltext :db/isComponent :db/noHistory)]
(is (s/validate datomic.db.DbId (:db/id result)))
(is (wild-match? {:db/id :*
:db/ident :weapon/type
:db/index true
:db/unique :db.unique/identity
:db/noHistory true
:db/cardinality :db.cardinality/many
:db/isComponent true
:db.install/_attribute :db.part/db
:db/fulltext true
:db/valueType :db.type/keyword}
result)))
edited Nov 4 '18 at 17:33
answered Nov 4 '18 at 15:24
Alan ThompsonAlan Thompson
13.4k22533
13.4k22533
Thanks, my (surprising?) conclusion is that everything works (and works well!) but the docs were out of date.
– agam
Nov 5 '18 at 19:29
add a comment |
Thanks, my (surprising?) conclusion is that everything works (and works well!) but the docs were out of date.
– agam
Nov 5 '18 at 19:29
Thanks, my (surprising?) conclusion is that everything works (and works well!) but the docs were out of date.
– agam
Nov 5 '18 at 19:29
Thanks, my (surprising?) conclusion is that everything works (and works well!) but the docs were out of date.
– agam
Nov 5 '18 at 19:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139065%2ftransacting-api-for-datomic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I've noticed another inconsistency: while my toy example now works (yay), the result is a hash-set, while the result in the tutorial is a vector; not sure what to make of this.
– agam
Nov 4 '18 at 8:51