2017-06-04 61 views
0

我正在編寫一個將參與者和資產添加到網絡的事務。將參與者添加到網絡中工作,但是當我嘗試訪問醫療資產文件註冊表時,該函數返回undefined。未定義無法調用

Error: TypeError: undefined not callable

交易的邏輯:

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); 
     }); 
} 

型號:

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 
} 

NPM的依賴關係:

"dependencies": { 
    "fabric-ca-client": "1.0.0-alpha.0", 
    "fabric-client": "1.0.0-alpha", 
    "homedir": "^0.6.0", 
    "composer-client": "^0.7.0", 
    "composer-rest-server": "^0.7.0" 
    } 

任何想法有什麼不對?

回答

1

假設註冊表爲空是不正確的。問題是業主不是一個關係。這只是一個字符串,我認爲這是允許的。

這導致了上述錯誤。

的修復:

medicalFile.owner = factory.newRelationship(namespace, 'Patient', newPatient.bsn); 
相關問題