Fork me on GitHub
#datomic
<
2021-06-03
>
Paulo Bardes02:06:25

@favila Thanks for the tip!

prnc12:06:17

Hi šŸ‘‹ In Datomic Cloud, what is the recommended way of getting a sorted result set from a query? Two variations on the theme that Iā€™m interested in would be sorted by transaction :db/txInstant or sorted by arbitrary attribute on the entity.

favila12:06:29

index-pull if there is one :avet or cardinality-many :aevt index that matches your results and desired order

favila12:06:41

otherwise, just sort in the application

prnc12:06:51

I see, thanks!

uwo16:06:18

I just want to double check, beyond :db/cas and transaction functions, which must be installed, there's no way to ensure a state before transacting, no?

Joe Lane16:06:46

@U09QBCNBY What kind of guarantees are you looking for?

uwo16:06:18

I want to ensure that no other transactions have touched the target datoms entity before committing the transaction. I would use cas, however I need to read one attribute and then set another, sadly.

uwo16:06:04

this is an ad hoc thing, otherwise we would just install a transaction function that could throw if the constraints weren't matched

Joe Lane16:06:45

I'm not sure why cas doesn't support what you want.

Joe Lane17:06:52

{:tx-data [[:db/cas 42 :no/touchy 100 100] [:db/add 9000 :iff/no-touchy-cas "winning?"]]}

uwo17:06:22

AH HA! I just leave the cas'd value the same -- I didn't realize that a single cas would cancel the entire transaction. That's great!!

Joe Lane17:06:47

Yay ACID šŸ™‚

uwo17:06:14

Right of course. Man I ask really embarrassing questions. thanks for entertaining them

Joe Lane17:06:43

Haha, no way @U09QBCNBY I love your questions!!

uwo17:06:53

Thanks Joe!