This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-24
Channels
- # announcements (1)
- # asami (10)
- # aws (1)
- # babashka (1)
- # beginners (105)
- # cider (13)
- # cljsrn (6)
- # clojure (42)
- # clojure-australia (4)
- # clojure-dev (7)
- # clojure-europe (26)
- # clojure-nl (2)
- # clojure-uk (13)
- # clojurescript (19)
- # code-reviews (3)
- # conjure (18)
- # core-async (4)
- # core-matrix (5)
- # cryogen (3)
- # datomic (27)
- # depstar (21)
- # emacs (2)
- # figwheel-main (9)
- # fulcro (18)
- # helix (7)
- # jobs (3)
- # jobs-discuss (15)
- # juxt (7)
- # kaocha (4)
- # lambdaisland (2)
- # leiningen (11)
- # luminus (1)
- # malli (6)
- # meander (9)
- # minimallist (4)
- # mount (3)
- # off-topic (3)
- # pathom (8)
- # pedestal (28)
- # rdf (13)
- # re-frame (7)
- # reagent (5)
- # shadow-cljs (3)
hi, how could I update the value of an attribute by applying a function on it, like in a Clojure atom, instead of just replacing it with a new value, thanks
https://docs.datomic.com/cloud/transactions/transaction-functions.html is maybe what you are looking for
understood, thanks
You could also do [:db/cas …]
, in which you specify your expected old value, as well as the new one. E.g. “If the account balance was 6 euros, then the account balance should now become 9 euros”. If you expectancy is not met, you’ll get an exception.
@danie thanks for the quick reply ! it seems so, but perhaps a bit too compact for someone new to Datomic like me, I'd need a clearer, complete example, thanks
@lennart.buit thanks for your quick reply ! what I am trying to implement is just apply a function to current value and get that replaced by that function application's output
Yeah, you can do that, just pull the current value, apply your function, and compare-and-swap old to new.
understood, thanks
Datomic 1.0.622 On-Prem now available: https://forum.datomic.com/t/datomic-1-0-6222-now-available/1700
What's the recommended solution, if there is one, for free form text search across multiple attributes? Bonus points for different matching algorithms and weighted results. Has anyone attempted to integrate Datomic with Elasticsearch? Thanks
Well, I'd say Elasticsearch is indeed a good choice, giving you a lot of flexibility for text search across multiple attributes straight out of the box.
There shouldn't be any issues with using Elasticseach with Datomic if you use the standard practice of storing your data in a real database (eg. Datomic) and only using Elasticsearch as a secondary view to the data.
Thanks. I worked with Postgres and Elasticsearch and this is the approach we took then too.
We use datomic cloud + elastic search in a similar scenario described by pyry. It suits us just fine
We use elastic search for the same purpose too. Even embedding the ES query inside datalog, so the queries are from the peer. This way the datomic client consumers do not need ES integration
@UHJH8MG6S I was hoping to hear something like this. Can you share any more details? An example maybe?
Basically we created a 2 (internal) libraries. 1 for monitoring the tx-log, and updating those values into ES. The other exposes some search functions (uses spandex to perform a query). We put that library on the classpath of our peer server. Which allows the client to use the functions in our internal library to be used in datalog:
{:query '{:find [?e]
:where [(ourthing/search ?client ?search-term) [?e ...]]
:in [$ ?client ?search-term]}
:args [(d/db ...), {:hosts [""]}, "Hello world!"]}
In order to get this to work we built a second (internal) library which monitors the tx log, and updates ES indexes for any attributes we're interested in searching.Most of this is very much WIP, but as far as I can tell right now it's a very viable solution.
I’m trying to use dev-local
to write a test that involves a datomic database.
I can open the connection and get a database, but when my code is done running, the program waits for about 30-40s before it completes.
Presumably this is because I’ve failed to shut down something related to datomic, but I cannot figure out how to close the connection or otherwise shut down the dev-local database.
(Note: if I never call datomic.client.api/connect
, the program shuts down immediately)
Here is my code:
#!/bin/sh
#_(
#_DEPS is same format as deps.edn. Multiline is okay.
DEPS='
{:deps {com.datomic/dev-local {:mvn/version "0.9.225"}
}}
'
#_You can put other options here
OPTS='
'
exec clojure $OPTS -Sdeps "$DEPS" "$0" "$@"
)
(require '[datomic.client.api :as d]
'[datomic.dev-local :as dl]
'[clojure.test :as ct :refer [is testing deftest use-fixtures]])
(deftest datomic-integration
(let [args {:server-type :dev-local
:system "test"
:db-name "movies"
}
client (d/client args)
_ (d/create-database client args)
;; If I don't call connect, the script exits immediately after
;; the tests run.
conn (d/connect client args)
]
(println (class conn)) ;; datomic.dev_local.impl.DurableConnection
(dl/release-db args)
(is (= 1 1))))
(ct/run-tests)