Commit 6f48e86f authored by Anastasios Kalogeropoulos's avatar Anastasios Kalogeropoulos
Browse files

get all queries cc function added

parent 4e956118
......@@ -63,3 +63,30 @@ func (t *SmartContract) ReadEvidentiaQuery(ctx contractapi.TransactionContextInt
return &evidentiaQuery, nil
}
func (s *SmartContract) GetAll(ctx contractapi.TransactionContextInterface) ([]*EvidentiaQuery, error) {
// range query with empty string for startKey and endKey does an
// open-ended query of all assets in the chaincode namespace.
resultsIterator, err := ctx.GetStub().GetStateByRange("", "")
if err != nil {
return nil, err
}
defer resultsIterator.Close()
var queries []*EvidentiaQuery
for resultsIterator.HasNext() {
queryResponse, err := resultsIterator.Next()
if err != nil {
return nil, err
}
var query EvidentiaQuery
err = json.Unmarshal(queryResponse.Value, &query)
if err != nil {
return nil, err
}
queries = append(queries, &query)
}
return queries, nil
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment