datomic 2019-11-26

Where do I find the upgrade instructions from solo to production?

Just choose a production compute stack instead of a solo compute stack. You should be running a split stack first

An attribute which is unique by identity allows us to use its value instead of a :db/id to identify an entity within a transaction. If no entity exists with that value then an entity is created, otherwise facts are stored about the existing entity. Do composite tuples work the same way? They are also :db.unique/identity, however they seem to operate more like :db.unique/value in that they throw an exception when the tuple value already exists.

Or in other words, can I take advantage of a tuple to update an existing entity? For example, change this player's colour based on the combination of their first and last name:

{:tx-data [{
            ; composite tuple attributes:
            :player/first-name "Jean-Luc"
            :player/last-name  "Picard"
            
            ; some fact to store about the existing entity
            :player/colour     "blue"
            }]}
Edit: the code example throws a Unique conflict exception when transacted a second time

You can indeed use a composite tuple for identity and upsert. You have to include the tuple itself in the transaction So in your example, if the unique attribute is called :player/first+last, you need to include a value for :player/first+last in your next transaction to get upsert

@kelveden has left the channel

Thanks @marshall, you just made my day.

👍 1

I came across that post a few months ago when I first encountered the same problem, but to be honest I didn't understand the resolution in the comments.

i'm attempting to transact a tuple ident and am getting the following exception:

(d/transact (client/get-conn)
            {:tx-data [
                       {:db/ident       :user/first+last
                        :db/valueType   :db.type/tuple
                        :db/tupleAttrs  [:user/first :user/last]
                        :db/cardinality :db.cardinality/one
                        :db/unique      :db.unique/identity}
                       ]})

Unable to resolve entity: :db/tupleAttrs
any ideas? i have no problem transacting it to another database an hour ago.

This db was created with an older (pre-tuple) version of datomic?

You need to transact these new schema attributes using administer-system

If so, you have to run d/administer-system as in the documentation

this applies to cloud as well?

silly question, of course it does as i'm missing the attributes 😉

great, that did the trick. thanks favila and ghadi!

is it technically possible/viable to downgrade the production primary compute group instance type to something cheaper as long as you don't have users?

the supported instance types are fixed

you can, however, reduce your ASG size to 1

if you don’t need HA

still, its a factor ten price difference at least

from solo - prod?

fair enough; we are definitely taking feedabck and considering options

also, you can ‘turn off’ the system over nights/weekends if it’s not a user-facing prod system

same technique - ASG to 0

as long as my customer is not live, I will have difficulty explaining this price to him

we’re also looking into tooling that will make that somewhat easier to do/manage

simultaneously, I need the architecture at some point, to develop against prod. only features like http-direct

or have staging/test query group separation

i need the platform running for 1-5 users testing on the customer site

turn off is no option

Are there plans to expose point-in-time queries via datomic analytics?

@darleilopes has joined the channel

When I create entities I always give them an attribute called :base/type , which is just a keyword, for instance :bank-account . I'd like to find all the entities (preferably that I've created) that don't have this attribute. I've asked this on Stack Overflow: https://stackoverflow.com/questions/58866423/find-all-entities-that-are-missing-a-particular-attribute, but no answers...

@cjmurphy you would have to somehow reduce the number of entities to check otherwise you're doing a full db scan. So I would write first the clause to identify all the entities you've created and then from those, find all the entities without this attribute.

Unfortunately it is not explained in the missing? section of the docs and all examples just happend to have clauses before the missing? predicate that makes the query work (`[?artist :artist/name ?name]`)

Thanks @me1740 that brings things together for me. I can work with knowing the name of an attribute in the entity that may not have a :base/type.

[:find [?entities ...]
       :in $ :where
       [?entities ::rule/splits ?s]
       [(missing? $ ?entities :base/type)]]