This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-27
Channels
- # admin-announcements (1)
- # announcements (11)
- # babashka (17)
- # beginners (26)
- # calva (6)
- # cider (2)
- # circleci (1)
- # clojure (41)
- # clojure-dev (1)
- # clojure-europe (31)
- # clojure-france (2)
- # clojure-italy (10)
- # clojure-nl (7)
- # clojure-norway (5)
- # clojure-spec (15)
- # clojure-uk (42)
- # clojurescript (4)
- # code-reviews (12)
- # conjure (10)
- # datalog (2)
- # datascript (15)
- # datomic (37)
- # emacs (1)
- # events (5)
- # fulcro (19)
- # jobs (1)
- # jobs-discuss (9)
- # kaocha (2)
- # luminus (14)
- # meander (4)
- # membrane (39)
- # off-topic (26)
- # other-languages (2)
- # re-frame (13)
- # reitit (6)
- # rewrite-clj (39)
- # sci (6)
- # shadow-cljs (33)
- # test-check (15)
- # vrac (17)
- # xtdb (7)
I have a query on a Datomic Ion that consistently returns partially different results when run remotely vs on the Ion. The query returns 9 results (both remotely & on-ion) but remotely returns correct entity-ids and on-ion returns 3 correct entity-ids and 6 empty/new entity-ids. I think this will be hard to reproduce b/c I can’t even reproduce it on a 2nd Ion with the same schema (it works correctly there). Here’s the query in case anyone can see something obviously wrong:
(d/q
'[:find ?mp
:in $ ?low ?high
:where
[?mp :membership-period/end ?end]
[(< ?low ?end)]
[(< ?end ?high)]]
db inst-low inst-high)
Has anyone experienced this strange inconsistent behavior before? I’d love to hear from you.i've seen inconsistencies when using >
<
operators on dates. try using [(.after ?date1 ?date2)]
Are you using (Date.) in the ion? I would confirm time zones aren’t messing this up.
Thanks both of you!
I’m using the standard Java (Date.) objects in the comparison. I also thought it might be a timezone issue, so I ran the same query with wider date ranges and got similarly strange results.
I was able to get the query working consistently using [(.before ?low ^java.util.Date ?end)]
.
I’m still not sure why Datomic was returning :db/ids for non-referenced entities in the results but at least I can move on…
Thanks again!
Good morning! I remember seeing/hearing somewhere that :db/index
is now superfluous, or, at least, we should actually always make it :db/index true
, since it's basically doing that under the hood in Datomic now anyhow... I can't find the source now, but the docs still state :db/index
defaults to false
- so is this something we still need to consider for our schema?
You are probably thinking of datomic cloud: it makes a value index for everything so it doesn’t have a :db/index attribute at all
For on prem nothing has changed, and you should still consider whether to index or not
Hi all, working through the https://docs.datomic.com/on-prem/tutorial.html I find myself missing a slightly more complex use case. For an example of order items, what if I wanted to edit an order and retract a specific item or update an item's amount? I find it a bit complicated when dealing with componenets
What’s so complicated about that ?
Do you have a code that you would like to share?
@UGMEQUCTV sure
(def schema
[{:db/ident :product/name
:db/cardinality :db.cardinality/one
:db/unique :db.unique/identity
:db/valueType :db.type/string}
{:db/ident :order/items
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}
{:db/ident :order/id
:db/valueType :db.type/long
:db/cardinality :db.cardinality/one
:db/unique :db.unique/identity}
{:db/ident :item/product
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one}
{:db/ident :item/amount
:db/valueType :db.type/long
:db/cardinality :db.cardinality/one}])
@(d/transact conn schema)
@(d/transact conn [{:product/name "coke"} {:product/name "pizza"}])
Then a simple order
@(d/transact
conn
[{:order/id 1
:order/items
[{:item/product [:product/name "pizza"] :item/amount 3}
{:item/product [:product/name "coke"] :item/amount 1}]}])
Now assuming there was a mistake and the client ordered just one pizza, can I write it with reference only to the order/id
? Because if I do the following it just adds another item
@(d/transact
conn
[{:order/id 1
:order/items [{:item/product [:product/name "pizza"] :item/amount 1}]}])
@UK0810AQ2 you will need the item id to update the amount. So here is the code that does that
(defn update-product [product-name amount]
(let [item-id (d/q '[:find ?eid .
:in $ ?product
:where
[?eid :item/product ?product]]
(d/db conn) [:product/name product-name])]
(d/transact conn [{:db/id item-id
:item/amount amount}])))
(update-product "pizza" 1)
(d/q '[:find ?count .
:where
[?id :item/product [:product/name "pizza"]]
[?id :item/amount ?count]]
(d/db conn))
just to push on this use case some more (because I've had similar wishes to @UK0810AQ2 's) ... @UGMEQUCTV since you are getting the item id first, and then transacting it, it's not concurrent safe, especially since Ben is talking about possible retracting the sub-entities (like replacing) ... I wonder if there is a way to do this in one transaction, maybe using a TX fn??
(another similar use case to this, is a many cardinality attr, and you want to replace the current set of values with new values, but it's important to do it in one transaction for concurrency concerns)
Somewhat out of date now, but Valentin’s Datofu library had some helpers for resetting to-many relations as a tx fn. It might be worth studying the code for ideas: https://github.com/vvvvalvalval/datofu#resetting-to-many-relationships
Hi, while choosing an AWS region for Datomic Cloud I found out that https://aws.amazon.com/local/africa/ is https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?qid=1598530512130&sr=0-1&ref_=srh_res_product_title. How do I go about choosing the Africa Region (Capetown)? Also, is it possible to migrate from one AWS region using Datomic Cloud to another AWS Region? e.g. AWS EU (London) to AWS Africa Region (Capetown). Thanks in advance for your answers.
About move across instances, Once you do a datomic backup, um can restore it in any other instance, including a local instance in your machine.
@U015L4S1C72 Datomic Cloud is not currently available in the South Africa region. I can investigate whether we could add support for that region in a future release. We don't currently have a built-in mechanism for transferring a Datomic Cloud database from one AWS region to another. However, because Datomic keeps the history of your entire database (the log) you could write a tool that reads the log of an existing database and transacts the same data into a new database in your new region.
Looking forward to it. I am from Nairobi, Kenya and the nearest AWS Region is South Africa, followed by UAE, India and then the EU. The EU regions are not bad because African fibre optic cables connect to the EU countries and many African companies use cloud providers that are thousands of miles away from their customers. Adding more regions would certainly help with latency. Thanks.
Sorry I didn't find the India Region. Maybe am restricted from choosing the India Region due to my location.
Thanks. Looking forward to it.
@U051F5T93 we attempted to launch in Stockholm region earlier this year, but AWS Marketplace didnt have the correct support there yet