datomic

How to sort result in a Datalog query

喜欢而已 提交于 2019-12-20 12:36:37
问题 I am using datomic with play framework. Play is amazing and datomic is fast. So a good combination overall. Since, I am new to datomic (and datalog i.e. query language datomic uses), I am unable to sort my result ( like we do, order by in sql). For example. if my query is : q= [:find ?title :where [?e :movie/title ?title] [?e :movie/director "Dave Swag"] [?e :movie/year ?year] [(sort ?year)] //here I am trying to sort by year ] It should return titles of the movies whose director was Dave

Why does Datomic yield the same temporary ID twice in a row when iterating?

走远了吗. 提交于 2019-12-18 09:16:00
问题 This will produce two different ids, which is great: #db/id[:db.part/user] #db/id[:db.part/user] but anything like the following (I tried a lot of ideas so far) will produce the same id twice, which is not what I want: (repeatedly 2 (fn [] #db/id[:db.part/user])) (for [n [1 2]] #db/id[:db.part/user]) All yield something like (#db/id[:db.part/user -1000774] #db/id[:db.part/user -1000774]) where the number produced is the same for each call. What I actually want is for the calls to NOT produce

Properties on Datomic ref relationships

我只是一个虾纸丫 提交于 2019-12-13 02:01:19
问题 I'm trying to model a schema where a list can have many items and each item can belong to many lists . It's clear to me that I can have a :list/items ref type to model the relationship, but I'd like to also have a rank attribute which determines an item's position in each list where it exists. How might one do such a thing? 回答1: The only answer I have - assuming that positioning is list dependent - is that you need to add an indirecting entity with a rank attribute. This isn't very pleasant.

Datomic query performance improvements

懵懂的女人 提交于 2019-12-12 13:56:12
问题 I have a schema that looks similar to this in a Datomic database: ; --- tenant {:db/id #db/id[:db.part/db] :db/ident :tenant/guid :db/unique :db.unique/identity :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db.install/_attribute :db.part/db} {:db/id #db/id[:db.part/db] :db/ident :tenant/name :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db.install/_attribute :db.part/db} {:db/id #db/id[:db.part/db] :db/ident :tenant/taks :db/valueType :db.type/ref :db

Getting the id of an inserted entity in datomic?

喜夏-厌秋 提交于 2019-12-12 08:22:42
问题 After I run a transaction in datomic to insert a value, how I can use the return value of the transaction to get the ids of any entities that were created? Here is a sample of the return value I get after an insert: #<promise$settable_future$reify__4841@7c92b2e9: {:db-before datomic.db.Db@62d0401f, :db-after datomic.db.Db@bba61dfc, :tx-data [#Datum{:e 13194139534331 :a 50 :v #inst "2013-06-19T11:38:08.025-00:00" :tx 13194139534331 :added true} #Datum{:e 17592186045436 ..... I can see the

Dealing with out-of-order messages stored in Datomic?

一个人想着一个人 提交于 2019-12-11 02:04:06
问题 Background In distributed systems messages can arrive in an out of order fashion. For example if message A is sent at time T1 and message B is sent at T2 there is a chance that B is received before A. This matters for example if A is a message such as "CustomerRegistered" and B is "CustomerUnregistered". In other databases I'd typically write a tombstone if CustomerUnregistered is received for a customer that is not present in the database. I can then check if this tombstone exists when the

Clojure RuntimeException - No reader function for tag db/id

ぐ巨炮叔叔 提交于 2019-12-10 07:31:35
问题 What is happening when I get this error in Clojure? java.lang.RuntimeException: No reader function for tag db/id 回答1: Tagged Literals This error message is related to a feature introduced in Clojure 1.7, tagged literals. Tagged literals are a simple means for extending what data types can be represented as literals in Clojure code or EDN data. Clojure ships with readers for two tagged literals, #inst and #uuid allowing literal representations of java.util.Date and java.util.UUID . Support for

How to deal with a variable in a library that needs to be set outside of it?

爷,独闯天下 提交于 2019-12-10 03:48:57
问题 I'm using Datomic in several projects and it's time to move all the common code to a small utilities library. One challenge is to deal with a shared database uri , on which most operations depend, but must be set by the project using the library. I wonder if there is a well-established way to do this. Here are some alternatives I've thought about: Dropping the uri symbol in the library and adding the uri as an argument to every function that accesses the database Altering it via alter-var

“No reader function” error using Datomic in Light Table

只愿长相守 提交于 2019-12-09 16:40:20
问题 When I eval this code in lighttable: (ns app.core (:require [datomic.api :refer [q] :as d] :reload-all)) (defn add-person [conn id] (d/transact conn [{:db/id #db/id[:db.part/user -1000001] :person/id id}])) I get: clojure.lang.ExceptionInfo: No reader function for tag id core.clj:4327 clojure.core/ex-info Anyone knows what is going on? 回答1: This tutorial is attributed to stuart halloway and Bobby Calderwood: (use :reload 'datomic.samples.repl) (easy!) (def conn (scratch-conn)) ;; in data, use

Datomic: schema for a to-many relationship with a 'reset' operation

好久不见. 提交于 2019-12-08 18:49:48
问题 I'm looking for feedback on an approach for modeling certain to-many relationships in Datomic. The problem Suppose I want to design the Datomic schema for a domain where a Person has a list of favorite Movies. For instance, John 's favorite movies are Gladiator , Star Wars , and Fight Club . The most obvious schema for modeling this in Datomic is with a cardinality-many attribute, e.g: #{["John" :person/favorite-movies "Gladiator"] ["John" :person/favorite-movies "Star Wars"] ["John" :person