datomic

SQL LIKE operator in datomic

♀尐吖头ヾ 提交于 2019-12-07 22:53:48
问题 I want to run a sql query, that given a search keyword, will find all users, where their name matches that pattern. i.e in raw SQL something like WHERE users.name LIKE "%foo%" How owuld I go about doing that? Current structure of query -> (defn find-users [db, search] (->> (d/q '[:find ?u :where [?u :user/uuid ?id] [?u :user/name ..] db) (map first))) 回答1: This is what I use. Maybe you can adapt it to your needs. (defn find-items "Full text search titles and descriptions for [search-term]"

Use event time instead of transaction time in Datomic?

那年仲夏 提交于 2019-12-07 15:01:00
问题 Background I'm using Datomic to store projections of events generated by other systems (projections in this case can be regarded as an entity in Datomic). These events have a timestamp associated with them that tells when the event was (for example) created. This is obviously not the same as the transaction time that Datomic will assign to the transaction when it stores a new attribute (based on the event) in the projection. Users of my application are not interested in the transaction time

Updating transaction in Datomic for an attribute that has many cardinality

醉酒当歌 提交于 2019-12-06 07:29:36
I have searched for two days and haven't seen any code that is closed to this. This is the only code in java that I seen and it's not exactly what I wanted. conn.transact(list(list("db.fn/cas", datomic_id, "attribute you want to update", old value, new value))).get(); I have tried this code with a single value in the old value and a single value in the new value but it just stack the information instead of overlaying it. Example: old value is chicken and new value is fish. After the transaction, it's [chicken, fish] instead of what I expected to be just [fish] and chicken will be move into

SQL LIKE operator in datomic

假如想象 提交于 2019-12-06 04:51:58
I want to run a sql query, that given a search keyword, will find all users, where their name matches that pattern. i.e in raw SQL something like WHERE users.name LIKE "%foo%" How owuld I go about doing that? Current structure of query -> (defn find-users [db, search] (->> (d/q '[:find ?u :where [?u :user/uuid ?id] [?u :user/name ..] db) (map first))) This is what I use. Maybe you can adapt it to your needs. (defn find-items "Full text search titles and descriptions for [search-term]" [search-term] (let [keyys [:item-id :title :description] rules '[[(finditem ?item ?term) [(fulltext $ :item

Use event time instead of transaction time in Datomic?

筅森魡賤 提交于 2019-12-06 02:14:12
Background I'm using Datomic to store projections of events generated by other systems (projections in this case can be regarded as an entity in Datomic). These events have a timestamp associated with them that tells when the event was (for example) created. This is obviously not the same as the transaction time that Datomic will assign to the transaction when it stores a new attribute (based on the event) in the projection. Users of my application are not interested in the transaction time but rather the event time. The reason why I'm using Datomic in the first place is to be able to get an

lein REPL server launch timed out

孤街醉人 提交于 2019-12-05 10:14:49
问题 in a liberator based clojure project we are using datomic as DB. After migrating our local dev DB to a S3 hosted one and adding the needed dependencies on our project.clj we cannot launch the REPL but the Liberator stack runs fine through lein run My guess is that the DB connection is messing things up, so, the question is, how can I somehow "debug" or figure out what's the reason of this lein repl timeout? My project.clj (defproject myproject "0.1.0-SNAPSHOT" :main myproject.core :jvm-opts [

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

不羁岁月 提交于 2019-12-05 05:20:05
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-root , or similar mechanism, in an init function Keeping it in the library as a dynamic var *uri* and

Getting the id of an inserted entity in datomic?

匆匆过客 提交于 2019-12-04 00:29:08
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 underlying datums...how can I extract their values? Use d/resolve-tempid . If you were to transact a single

lein REPL server launch timed out

社会主义新天地 提交于 2019-12-03 22:43:42
in a liberator based clojure project we are using datomic as DB. After migrating our local dev DB to a S3 hosted one and adding the needed dependencies on our project.clj we cannot launch the REPL but the Liberator stack runs fine through lein run My guess is that the DB connection is messing things up, so, the question is, how can I somehow "debug" or figure out what's the reason of this lein repl timeout? My project.clj (defproject myproject "0.1.0-SNAPSHOT" :main myproject.core :jvm-opts ["-Xmx1G"] :datomic {:schemas ["resources" ["myproject-schema.edn" ]]} :plugins [[lein-ring "0.8.10"]] ;

How to sort result in a Datalog query

痞子三分冷 提交于 2019-12-03 06:56:52
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 Swag and result is ordered by year in which image was released. Thankyou :) If you want to sort your