You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm thinking bout updating the middleware component to add support for queries on standard projections. Would that be useful?
sounds good
It is possible to query standard projections. One QueryStandardProjection query could do it, but we would loose out on permissions etc.. so... quick and dirty
trait StandardQueryTrait {
public function streamName(): string {
return $this->metadata()['stream_name'];
}
public function result($state) {
return $state;
}
}
abstract class QueryStandardProjection extends Messaging\Query implements Messaging\PayloadConstructable {
use Messaging\StandardQueryTrait;
}
class StandardQueryHandler {
private $projectionManager;
public function __construct(ProjectionManager $projectionManager)
{
$this-> projectionManager = $projectionManager;
}
public function onEvent(QueryStandardProjection $query, Deferred $deferred)
{
// use projectionManager to retrieve state of $query->streamName()
$deferred->resolve($query->makeResult($state));
}
}
class MyQuery extends QueryStandardProjection {
public function result($state) {
return ValueObject::fromArray($state);
}
}
I now understand Query's as used in the standard projections are not traditional queries but rather projections without persisted state.... So that might skew this a little... Thought I needed to point that out...
I don't think it makes sense to have this as middleware. An event store query can use some time, it's more for answering some questions that arise from the business, where someone wants to know some stats f.e. and he is happy, when you give him the result the next few days. There is no need to have this exposed through the Api I think.
From @basz on March 16, 2017 15:37
on chat
It is possible to query standard projections. One QueryStandardProjection query could do it, but we would loose out on permissions etc.. so... quick and dirty
routes
Which add a StandardQueryMiddleware.
It's just an rough idea... Looking for input
Copied from original issue: prooph/psr7-middleware#22
The text was updated successfully, but these errors were encountered: