title: What is the best approach in Solidity for pagination (straightforward and based on some filter(s)) capabilities?
body: <p>Let's suppose that we have following structures in Solidity contract : </p>
  
  <pre><code>struct EntityA {
  string lessThen32ByteString1;
  string moreThen32ByteString1;
  string lessThen32ByteString2;
  string moreThen32ByteString3;
  bool flag;
  uint var1;
  uint var2;
  uint var3;
  uint var4;
  ProposalStatus proposalStatus;}
  
  // 100K entities EntityA[] public items;
  </code></pre>
  
  <p>We have now following implementation (with helper functions for string to byte32 conversion, splitting string to a few byte32 parts and so on) : </p>
  
  <pre><code>function getChunkOfPart1EntityADetails(uint filterAsUint, uint offset, uint limit) public constant
  returns (bytes32[100] lessThen32ByteString1Arr, bytes32[100] moreThen32ByteString1PrefixArr, bytes32[100] moreThen32ByteString1SuffixArr) {
  }
  
  function getChunkOfPart2EntityADetails(uint filterAsUint, uint offset, uint limit) public constant
  returns (bytes32[100] lessThen32ByteString2Arr, bytes32[100] moreThen32ByteString2PrefixArr, bytes32[100] moreThen32ByteString2SuffixArr) {
  }
  
  function getChunkOfPart3EntityADetails(uint filterAsUint, uint offset, uint limit) public constant
  returns (bool[100] flagArr, uint[100] var1Arr, uint[100] var2Arr, uint[100] var3Arr, uint[100] var4Arr, ProposalStatus[100] proposalStatusArr,) {
  }
  </code></pre>
  
  <p>Current implementation does not look good from design perspective, furthermore each additional filter support requires contract changes due to absence any query language support.</p>
  
  <p>Use case example : retrieve 10 entities based on specified proposalStatus and offset 50 (6th page, page size is 10 entities (maybe 20, 50, 100))</p>