将两个值传递到 hyperledger fabric 查询的语法?
Syntax for passing two values into a query for hyperledger fabric?
我有这个 hyperledger composer 查询,其中在 _$option
和 _$trader
中传递了两个值。
query selectCallPositionForSeller {
description: "Select call position based on ID"
statement:
SELECT org.tradenetwork.Trader
WHERE (callPosition.option == _$option AND user_id == _$trader )
}
其中 callPosition 是一组概念。我正试图这样称呼。
const selectByContract = await query('selectCallPositionForSeller', {'option': option}, {'trader': seller});
但我认为这种语法不正确。传递两个值的正确语法是什么?
也是user_id = _$trader
比较对象的正确方法吗?
hyperledger fabric 是否允许可变数量的参数? (这是我在查询中假设的)。
我认为您的语法不正确。尝试这样调用:
return query('selectCallPositionForSeller', { "option": option, "trader": seller})
并且,为了以防万一,把 select 像这样:
query selectCallPositionForSeller {
description: "Select call position based on ID"
statement:
SELECT org.tradenetwork.Trader
WHERE ((callPosition.option == _$option) AND (user_id == _$trader))
}
希望对您有所帮助!
我想 post 回答这个问题,因为另一个答案不是 100% 正确,这可能对某些人有帮助。
这是查询(调用位置是 concept
)
query selectSellerByContractAndCall {
description: "Select call position based on seller ID"
statement:
SELECT org.mining3.tradenetwork.Trader
WHERE ((callPosition CONTAINS (option == _$option)) AND (user_id == _$seller))
}
而且是这样叫的
const selectSellerByContractAndCall = await query('selectSellerByContractAndCall',
{'option': 'resource:org.mining3.tradenetwork.Option#' + option.optionId, 'seller': seller.user_id });
这是将对象(即选项)传递到查询中的正确方法。这可以有这样的逻辑。
for(cp of selectSellerByContractAndCall[0].callPosition){
//logic here
}
我有这个 hyperledger composer 查询,其中在 _$option
和 _$trader
中传递了两个值。
query selectCallPositionForSeller {
description: "Select call position based on ID"
statement:
SELECT org.tradenetwork.Trader
WHERE (callPosition.option == _$option AND user_id == _$trader )
}
其中 callPosition 是一组概念。我正试图这样称呼。
const selectByContract = await query('selectCallPositionForSeller', {'option': option}, {'trader': seller});
但我认为这种语法不正确。传递两个值的正确语法是什么?
也是user_id = _$trader
比较对象的正确方法吗?
hyperledger fabric 是否允许可变数量的参数? (这是我在查询中假设的)。
我认为您的语法不正确。尝试这样调用:
return query('selectCallPositionForSeller', { "option": option, "trader": seller})
并且,为了以防万一,把 select 像这样:
query selectCallPositionForSeller {
description: "Select call position based on ID"
statement:
SELECT org.tradenetwork.Trader
WHERE ((callPosition.option == _$option) AND (user_id == _$trader))
}
希望对您有所帮助!
我想 post 回答这个问题,因为另一个答案不是 100% 正确,这可能对某些人有帮助。
这是查询(调用位置是 concept
)
query selectSellerByContractAndCall {
description: "Select call position based on seller ID"
statement:
SELECT org.mining3.tradenetwork.Trader
WHERE ((callPosition CONTAINS (option == _$option)) AND (user_id == _$seller))
}
而且是这样叫的
const selectSellerByContractAndCall = await query('selectSellerByContractAndCall',
{'option': 'resource:org.mining3.tradenetwork.Option#' + option.optionId, 'seller': seller.user_id });
这是将对象(即选项)传递到查询中的正确方法。这可以有这样的逻辑。
for(cp of selectSellerByContractAndCall[0].callPosition){
//logic here
}