Hyperledger composer @在docker上本地运行时返回抛出错误

Hyperledger composer @在docker上本地运行时返回抛出错误,hyperledger-composer,Hyperledger Composer,我正在尝试从事务返回资产数组。因此,根据语法,我在cto文件中添加了@returns和@commit(false),但其抛出错误如下 ✖ Installing business network. This may take a minute... ParseException: Expected ")", "-", "false", "true", comment, end of line, number, string or whitespace but "P" found. File m

我正在尝试从事务返回资产数组。因此,根据语法,我在cto文件中添加了
@returns
@commit(false)
,但其抛出错误如下

✖ Installing business network. This may take a minute...
ParseException: Expected ")", "-", "false", "true", comment, end of 
line, number, string or whitespace but "P" found. File 
models/org.zcon.healthcare.cto line 370 column 10
Command failed
当我删除@returns注释时,它不会抛出任何错误。 当我从@returns注释中删除参数“Patient[]”时,它不会抛出任何错误。。但这违反了语法,对吗? 我使用docker swarm在本地运行应用程序

我的docker composer版本是v0.19.12

怎么了?这有什么问题吗

如果您想在cto文件中查看事务定义,请使用

@commit(false)
@returns(Patient[]) 
transaction SearchPatient{
  o String firstName optional
  o String lastName optional
}
和在逻辑文件中

/**
 * Sample transaction
 * @param {org.zcon.healthcare.SearchPatient} tx
 * @returns{org.zcon.healthcare.Patient[]}
 * @transaction
 */
async function SearchPatient(tx){
    let queryString = `SELECT org.zcon.healthcare.Patient WHERE (`;
    let conditions = [];
    if (tx.hasOwnProperty('firstName')) {
        var firstName =tx.firstName;
        conditions.push(`(firstName == "${firstName}")`)
    };
    if (tx.hasOwnProperty('lastName')) {
        var lastName = tx.lastName;
        conditions.push(`(lastName == "${lastName}")`)
    };
    queryString += conditions.join(' AND ') + ')';
    let finalQuery =  buildQuery(queryString);
    const searchPatient = await query(finalQuery);
    if(searchPatient.length ==0){
        throw "No Patient Records found!!"
    }else
      return searchPatient;   
}

我在
composer网络安装中没有看到这个错误(部署到正在运行的结构中)。我用您的型号和代码进行了网络安装(请参见屏幕截图)。我建议您的错误可能在您的业务网络的其他地方?你能把你得到的错误的完整顺序加起来吗?你是如何建立你的bna文件的

我还尝试了你的代码(结尾…):

并且可以很好地看到返回的结果(如console.log所示-只需使用不同的网络名称,仅供参考)


在composer bluemix中,它的运行非常完美。上面的代码是我贴的。但是当我在本地运行它时,我需要从cto文件中的@returns注释中删除参数“patient[]”。它给出了参数的错误。我在构建bna文件时出错。Im使用cli“composer archive create--sourceType dir--sourceName”构建bna文件-a./dist/healthcare network.bna.让我更正我的评论。我在安装网络时发现了错误。正在生成BNA文件,没有问题。您是否可以通过执行composer-v来确认CLI的版本,以检查您使用的是最新版本
const searchPatient = await query(finalQuery);
    console.log("results are " + searchPatient);
    console.log("element 1 of array is " + searchPatient[0]);
    if(searchPatient.length ==0){
        throw "No Patient Records found!!"
    } else
     return searchPatient;   
}