MCPcopy
hub / github.com/yeasy/blockchain_guide / GetCompanies

Method GetCompanies

11_app_dev/chaincode_example03.go:257–271  ·  view source on GitHub ↗
(ctx contractapi.TransactionContextInterface)

Source from the content-addressed store, hash-verified

255}
256
257func (s *SmartContract) GetCompanies(ctx contractapi.TransactionContextInterface) ([]Company, error) {
258 count, err := currentID(ctx, companyCounterKey)
259 if err != nil {
260 return nil, err
261 }
262 companies := make([]Company, 0, count)
263 for id := 0; id < count; id++ {
264 company, err := readCompany(ctx, id)
265 if err != nil {
266 return nil, err
267 }
268 companies = append(companies, *company)
269 }
270 return companies, nil
271}
272
273// GetCompanys keeps the historical example name available.
274func (s *SmartContract) GetCompanys(ctx contractapi.TransactionContextInterface) ([]Company, error) {

Callers 1

GetCompanysMethod · 0.95

Calls 2

readCompanyFunction · 0.85
currentIDFunction · 0.70

Tested by

no test coverage detected