首页 > 解决方案 > Hyperledger Composer 查询处理器函数返回一个空白数组

问题描述

我正在尝试在 Hyperledger Composer 中编写查询处理器函数。但是,它只是返回一个空数组'[]',我不知道为什么。从 'org.land.Deal' 发出 GET 请求时。我有 2 件物品被退回。但是从查询处理器函数中,只返回空白数组。

这是交易功能:

/**
* Get Live Deals
* @param {org.land.GetLiveDeals} getLiveDeals - the transaction
* @transaction
*/

async function getLiveDeals(){
  const liveDeals = [];
  const dealRegistry = await getAssetRegistry('org.land.Deal');
  const allDeals = await assetRegistry.getAll();

  for(const deal of allDeals){
    liveDeals.push(deal);
  }

  return liveDeals;
} 

这是交易模型:

@commit(false)
@returns(Deal[])
  transaction GetLiveDeals {
} 

标签: hyperledger-fabrichyperledgerhyperledger-composer

解决方案


我希望这种改变会奏效;

const allDeals = 等待 dealRegistry.getAll();

有关更多信息,请参考 - Composer getAll()


推荐阅读