run method

Stream<T> run()

Execute this Query on the datastore.

Outside of transactions this method might return stale data or may not return the newest updates performed on the datastore since updates will be reflected in the indices in an eventual consistent way.

Implementation

Stream<T> run() {
  ds.Key? ancestorKey;
  if (_ancestorKey != null) {
    ancestorKey = _db.modelDB.toDatastoreKey(_ancestorKey!);
  }
  var query = ds.Query(
      ancestorKey: ancestorKey,
      kind: _kind,
      filters: _filters,
      orders: _orders,
      offset: _offset,
      limit: _limit);

  ds.Partition? partition;
  if (_partition != null) {
    partition = ds.Partition(_partition!.namespace);
  }

  return StreamFromPages<ds.Entity>((int pageSize) {
    if (_transaction != null) {
      if (partition != null) {
        return _db.datastore
            .query(query, transaction: _transaction!, partition: partition);
      }
      return _db.datastore.query(query, transaction: _transaction!);
    }
    if (partition != null) {
      return _db.datastore.query(query, partition: partition);
    }
    return _db.datastore.query(query);
  }).stream.map<T>((e) => _db.modelDB.fromDatastoreEntity(e)!);
}