1

I found that it is possible to define up to 16 secondary indices for a multi index table. Is it possible to return data from the table using these secondary key? I have a table like,

enter image description here

result is set as secondary index. Now I want to retrieve names of all passed students only. Provided, the code and scope are _self and primary keys are randomly generated. Is it possible or is there any alternative solution for the same?

1 Answer 1

1

I'm unaware of a way to not return certain rows, however I believe you can achieve similar results with something like this:

uint64_t get_secondary_1() const { return result == "pass";}

This will return your data with all the students who passed first, followed by those who didn't. So once you see the first failer, you can stop reading from the table.

1
  • 1
    Alternatively, you might have success with putting all passing students in a specific scope and all failing students in another scope. It will require a bit more overhead within your contract, but this will achieve the desired result of conditionally returning table rows. Commented Apr 26, 2019 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.