Fork me on GitHub
#datomic
<
2020-09-11
>
nando22:09:44

If an attribute has a :db.cardinality/many, can it have other value types besides :db.type/ref? If so, what does a query or pull of that attribute return? A vector? A set? And what does a transaction expect if multiple values are passed into an attribute with a cardinality of many?

favila22:09:04

Cardinality many means you are allowed more than one assertion datom per e+a at a time

favila22:09:20

They’re still separate assertions

favila22:09:10

So in query there is no difference

favila22:09:56

In pull results, they are vectors of values, but they will be unique

favila22:09:13

And any type can be cardinality many

nando22:09:27

So I cannot transact several values in an array, for instance. They should be in separate maps?

favila22:09:26

You can have more than one db/assert

favila22:09:00

And a map with a set value will desugar to multiple assertions

favila22:09:38

I want to emphasize that each value is from separate datom. It’s not that you have a datom with many values in it

nando22:09:56

Oh, good. I'm working with a web app.

favila22:09:02

The vector you get from pulls, and the transaction map form are projections

nando22:09:19

Understand they are separate datoms, good.

nando22:09:50

Ok, so I'll work it out through experimentation from here. Thanks for the pointers!

nando22:09:26

I'm so used to relational databases, I'm not sure what mental model I should have here.