E.g. I’m transacting schema
(def movie-schema [
{
:db/ident :org/code
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/unique :db.unique/value
}
{
:db/ident :org/users
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true
}
{
:db/ident :user/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/unique :db.unique/value
}
])
(d/transact conn movie-schema)
Where :org/users is component
And data according to the schema:
(def first-movies
[
{
:db/id "user1"
:user/name "user1"
}
{
:db/id "user2"
:user/name "user2"
}
{
:org/code "org1"
:org/users ["user1" "user2"]
}
{
:org/code "org2"
:org/users ["user1" "user2"]
}
])
Actually I would expect that datomic will fail such transaction because of trying to set the same users among different organizations otherwise an example provided on datomic blog for Order and its LineItem is invalid because the same LineItem can’t be shared across more then one order