未定义不可调用

时间:2017-06-04 10:39:57

标签: hyperledger-fabric hyperledger-composer

我正在编写一个将参与者和资产添加到网络的交易。将参与者添加到网络有效,但是当我尝试访问医疗资产文件注册表时,该函数返回undefined。

  

错误:TypeError:undefined not callable

交易的逻辑:

ssh otherhost /bin/bash << EOF
  ls some_folder; 
  ./someaction.sh 'some params'
  pwd
  ./some_other_action 'other params'
EOF

型号:

return getParticipantRegistry(namespace + '.Patient')
        .then(function (patientRegistry) {
            return patientRegistry.add(newPatient);
        }).then(function() {
            return getAssetRegistry('nl.epd.blockchain.MedicalFile');
        }).then(function (registry) {
            var medicalFile = factory.newResource(namespace, 'MedicalFile', "test");
            medicalFile.id = "test";
            medicalFile.owner = newPatient.bsn;
            medicalFile.mentors = [];
            medicalFile.permissions = [];
            medicalFile.allergies = [];
            medicalFile.treatments = [];
            medicalFile.medicine = [];

            // registry is undefined
            return registry.add(medicalFile);
        });
}

NPM依赖项:

namespace nl.epd.blockchain

asset MedicalFile identified by id {
  o String                      id
  --> Patient                   owner
  --> Patient[]                 mentors
  o OrganisationPermission[]  permissions
  o Visit[]                   visits
  o String[]                  allergies
  o Treatment[]               treatments
  o Medicine[]                medicine
}

participant Patient identified by bsn {
  o String bsn
  o String firstName
  o String namePrefix optional
  o String lastName
  o String email
  o String telephoneNumber
  o String birthday
  o String gender
  o String city
  o String zipCode
  o String street
  o String houseNumber
  o String houseNumberExtra optional
}

知道什么是错的吗?

1 个答案:

答案 0 :(得分:1)

注册表为空的假设是不正确的。问题是所有者不是关系。它只是一个字符串,我认为这是允许的。

这导致了上述错误。

修复:

medicalFile.owner = factory.newRelationship(namespace, 'Patient', newPatient.bsn);