我对s/union的理解是,您可以使用它来组合两个处于同一层次结构的spec,例如(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?)))
我在这里指定了“Get”在内部层次上的可能值(包含“TableName”和“Key”作为键的映射)以及“TransactItems”在外部层次上可能值(包含“Get”作为键的映射数组或包含“Put”和“ConditionCheck”作为键的映射数组)。
来源:
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactGetItems.html