go.mercari.io/datastore@v1.8.2/boom/query.go (about)

     1  package boom
     2  
     3  import "go.mercari.io/datastore"
     4  
     5  // Iterator is the result of running a query.
     6  type Iterator struct {
     7  	bm *Boom
     8  	it datastore.Iterator
     9  }
    10  
    11  // Next returns the key of the next result. When there are no more results,
    12  // iterator.Done is returned as the error.
    13  //
    14  // If the query is not keys only and dst is non-nil, it also loads the entity
    15  // stored for that key into the struct pointer or PropertyLoadSaver dst, with
    16  // the same semantics and possible errors as for the Get function.
    17  func (it *Iterator) Next(dst interface{}) (datastore.Key, error) {
    18  	key, err := it.it.Next(dst)
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  
    23  	if dst != nil {
    24  		err = it.bm.setStructKey(dst, key)
    25  		if err != nil {
    26  			return nil, err
    27  		}
    28  	}
    29  
    30  	return key, nil
    31  }
    32  
    33  // Cursor returns a cursor for the iterator's current location.
    34  func (it *Iterator) Cursor() (datastore.Cursor, error) {
    35  	return it.it.Cursor()
    36  }