title: Scylla gocqlx how to implement pagination similar to a cursor
body: <p>I'm using Scylla to save parties created by a users. The method below returns a list of parties created by a user. I currently return all parties without allowing pagination, but I'm trying to implement Pagination for the method below but I still don't quite understand how pagination is handled with Scylla.<br />
  My guess would be that a cursor can be passed to a query. Based on this <a href="https://github.com/scylladb/gocqlx/blob/master/example_test.go#L434" rel="nofollow noreferrer">example</a> it looks like the <code>PageState</code> can be used to pass something similar to a cursor.<br />
  I would appreciate a short explanation what <code>PageState</code> is and if I should use it to accomplish token based pagination. It would also be great if an example could be provided that shows how a new <code>PageState</code> can be returned to the client and used to fetch a new page on a second request.</p>
  <pre class="lang-golang prettyprint-override"><code>func (pq *partyQuery) GetByUser(ctx context.Context, uId string) ([]datastruct.Party, error) {
      var result []datastruct.Party
      stmt, names := qb.
          Select(TABLE_NAME).
          Where(qb.Eq(&quot;user_id&quot;)).
          ToCql()
  
      err := pq.sess.
          Query(stmt, names).
          BindMap((qb.M{&quot;user_id&quot;: uId})).
          PageSize(10).
          Iter().
          Select(&amp;result)
      if err != nil {
          log.Println(err)
          return []datastruct.Party{}, errors.New(&quot;no parties found&quot;)
      }
  
      return result, nil
  }
  </code></pre>
  <p>Thanks in advance and I appreciate your time.</p>
  <h2>Edit</h2>
  <p>For anybody interested, this is how I transformed my function to allow paging:</p>
  <pre class="lang-golang prettyprint-override"><code>func (pq *partyQuery) GetByUser(ctx context.Context, uId string, page []byte) (result []datastruct.Party, nextPage []byte, err error) {
      stmt, names := qb.
          Select(TABLE_NAME).
          Where(qb.Eq(&quot;user_id&quot;)).
          ToCql()
  
      q := pq.sess.
          Query(stmt, names).
          BindMap((qb.M{&quot;user_id&quot;: uId}))
      defer q.Release()
  
      q.PageState(page)
      q.PageSize(10)
  
      iter := q.Iter()
      err = iter.Select(&amp;result)
      if err != nil {
          log.Println(err)
          return []datastruct.Party{}, nil, errors.New(&quot;no parties found&quot;)
      }
  
      return result, iter.PageState(), nil
  }
  </code></pre>