ORDER BY 在命名查询中不起作用

2024-04-27

我有一个带有 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(使用前将#替换为@)

ORDER BY 在命名查询中不起作用 的相关文章

  • Woocommerce 购物车通知显示多次

    我有一个功能正常工作 除了它在购物车中显示通知两次而不是一次 该功能应用折扣并显示通知 该函数查找特定类别的商品并添加总数 如果满足折扣金额 则应用折扣并显示通知 现在 即使购物车中只有一件商品 它也会显示两次通知 我尝试过添加wc cle

随机推荐