我有一个带有 ORDER BY 子句的命名查询:
`query OrdersByRequesterSort {
description: "Select all orders by requester"
statement:
SELECT org.test.sample.Order
WHERE (requester == _$requesterParam)
ORDER BY [placeTimestamp DESC]
}`
这是根据我看到她的查询而设计的:
https://hyperledger.github.io/composer/reference/query-language.html https://hyperledger.github.io/composer/reference/query-language.html
当我尝试执行此查询时,出现以下错误:
`
{
"error": {
"statusCode": 500,
"name": "Error",
"message": "Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: http: read on closed response body)",
"stack": "Error: Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: http: read on closed response body)\n at channel.queryByChaincode.then.catch (/Users/bower/.nvm/versions/node/v6.3.0/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:779:34)"
}
}`
难道我做错了什么?支持吗?
提前致谢。
对于我的网络,我按时间戳对从 HistorianRecord 返回的查询进行排序:
query getAllHistorianRecords {
description: "getTradeRelatedHistorianRecords"
statement:
SELECT org.hyperledger.composer.system.HistorianRecord
WHERE (transactionTimestamp > '0000-01-01T00:00:00.000Z')
ORDER BY [transactionTimestamp ASC]
}
为了使这个ORDER BY
声明工作我必须在 CouchDB 中创建一个索引。如果您使用脚本来创建结构,您的数据库应该位于http://localhost:5984/_utils/#database/composerchannel/_all_docs
.
curl -X POST --header 'Content-Type: application/json' --header
'Accept: application/json' -d '
{
"index": {
"fields": [
{
"data.transactionTimestamp": "asc"
}
]
},
"type": "json"
}' 'http://localhost:5984/composerchannel/_index'
这个curl将创建一个索引,查询可以使用该索引来启用ORDER BY
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)