Query Language : Query request on reference

微笑、不失礼 提交于 2019-12-06 04:40:45

Example on how to 'request it' is shown in the REST API section of the Queries tutorial https://hyperledger.github.io/composer/tutorials/queries

If you mean: request it from within a Transaction Processor function, using the APIs - there is an example in the same tutorial, of calling a Query function eg.

/**
 * Remove all high volume commodities
 * @param {org.acme.biznet.RemoveHighQuantityCommodities} remove - the remove to be processed
 * @transaction
 */

function removeHighQuantityCommodities(remove) {

return getAssetRegistry('org.acme.biznet.Commodity')
    .then(function (assetRegistry) {
        return query('selectCommoditiesWithHighQuantity')
            .then(function (results) {
           // process results objects etc

so using your query - you might do something like:

var tx_owner = tx.owner; // passed into the Transaction Processor for example
return query('selectCommoditiesByOwner', {
   "owner": tx_owner    // eg "resource:org.acme.trading.Trader#trader1"
})
.then(function (results) {
   // do something

hope this helps. See further reference here -> https://hyperledger.github.io/composer//reference/query-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!