在HyperLedger Composer查询中获取资产计数? [英] Get Count of assets in HyperLedger Composer Query?

查看:44
本文介绍了在HyperLedger Composer查询中获取资产计数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在HyperLedger Composer中编写一个查询,该查询向我返回我在超级账本中拥有的资产数量. 我有成千上万的记录.我不想全部获取它们并计算计数.数据传输会很慢

I want to write a query in HyperLedger Composer that returns me the count of assets that I have in hyper ledger. I have thousands of records. I don't want to fetch them all and calculate count. Data transfer will be slow

我希望查询返回计数.

推荐答案

不幸的是,在作曲家查询语言中没有count.

Unfortunately there is no count in the composer query language.

您将必须创建查询以选择所有资产,然后检查结果的长度.例如,使用基本示例网络:

You would have to create a query to select all the assets then check the length of the results. For example with the Basic Sample Network:

query selectAssets {
 description: "Select all assets"
 statement:
   SELECT org.example.basic.SampleAsset
}

然后执行它:

let results = await query('selectAssets');
let count = results.length;

这篇关于在HyperLedger Composer查询中获取资产计数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆