如何为数组概念中的属性编写查询。 示例:根据城市属性获取地址。
namespace org.sample.basic
participant User identified by userId{
o String userId
o Address[] address optional
}
concept Address {
o String address1
o String address2
o String city
o String state
o Integer zipcode
o String country
o Boolean isAddressValidated default = false
}
答案 0 :(得分:0)
给出的数据:
{ "$class": "org.sample.basic.User", "userId": "id1", "address": [ { $class": "org.sample.basic.Address", "address1": "the-vines", "city": "newyork" }, { $class": "org.sample.basic.Address", "address1": "the-gables", "city": "dallas" } ] } // and so on
您的querydef(并非在所有字段中都列出):
query myquery {
description: "Select all x" statement:
SELECT org.sample.basic.User
WHERE (address CONTAINS (city == "dallas") OR (city == "newyork") )
}
答案 1 :(得分:-1)
希望您使用的是Hyperledger查询语言。你可以尝试这样的事情吗?
SELECT org.sample.basic.User
WHERE ( address CONTAINS (city== _$city) )