我对s/union的理解是,您将使用它来组合处于相同层次级别的两个规格,如(s/union ::user/private ::user/public)。
我所需要的是一个像这个JSON结构一样的层次结构
{"TransactItems": [{"Get": {"TableName": "string", "Key": "string"}}]}
(s/def ::transact-schema (s/schema [::TableName ::Item ::Key ::ConditionExpression]))
(s/def ::Get (s/select ::transact-schema [::TableName ::Key]))
(s/def ::ConditionCheck (s/select ::transact-schema [::TableName ::Key ::ConditionExpression]))
(s/def ::Put (s/select ::transact-schema [::TableName ::Item]))
(s/def ::TransactGetItem (s/schema [::Get]))
(s/def ::TransactWriteItem (s/schema [::ConditionCheck ::Put]))
(s/def ::TransactItems
(s/or :get (s/coll-of ::TransactGetItem :kind vector?)
:write (s/coll-of ::TransactWriteItem :kind vector?)))
这里我指定了内部层“获取”的值可以是一个包含“TableName”和“Key”作为键的映射,以及外部层“TransactItems”的值可以是一个包含“Get”作为键的映射数组,或者是一个包含“Put”和“ConditionCheck”作为键的映射数组。
来源:
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactGetItems.html