Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ $writtenEvents = $client->writeEvents([

*Note that according to the CloudEvents standard, event IDs must be of type string.*

#### Using the `isEventQlTrue` precondition
#### Using the `isEventQlQueryTrue` precondition

If you want to write events depending on an EventQL query, use the `IsEventQlTrue` function to create a precondition:
If you want to write events depending on an EventQL query, use the `IsEventQlQueryTrue` function to create a precondition:

```php
use Thenativeweb\Eventsourcingdb\IsEventQlTrue;
use Thenativeweb\Eventsourcingdb\IsEventQlQueryTrue;

$writtenEvents = $client->writeEvents([
// events
], [
new IsEventQlTrue("FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT() < 10")
new IsEventQlQueryTrue("FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT() < 10")
]);
```

Expand Down
4 changes: 2 additions & 2 deletions src/IsEventQlTrue.php → src/IsEventQlQueryTrue.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use JsonSerializable;

final readonly class IsEventQlTrue implements JsonSerializable
final readonly class IsEventQlQueryTrue implements JsonSerializable
{
public function __construct(
public string $query,
Expand All @@ -16,7 +16,7 @@ public function __construct(
public function jsonSerialize(): array
{
return [
'type' => 'isEventQlTrue',
'type' => 'isEventQlQueryTrue',
'payload' => [
'query' => $this->query,
],
Expand Down
6 changes: 3 additions & 3 deletions tests/WriteEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use PHPUnit\Framework\TestCase;
use Thenativeweb\Eventsourcingdb\CloudEvent;
use Thenativeweb\Eventsourcingdb\EventCandidate;
use Thenativeweb\Eventsourcingdb\IsEventQlTrue;
use Thenativeweb\Eventsourcingdb\IsEventQlQueryTrue;
use Thenativeweb\Eventsourcingdb\IsSubjectOnEventId;
use Thenativeweb\Eventsourcingdb\IsSubjectPristine;
use Thenativeweb\Eventsourcingdb\Tests\ClientTestTrait;
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testSupportsTheIsSubjectOnEventIdPrecondition(): void
);
}

public function testSupportsTheIsEventQlTruePrecondition(): void
public function testSupportsTheIsEventQlQueryTruePrecondition(): void
{
$firstEvent = new EventCandidate(
source: 'https://www.eventsourcingdb.io',
Expand Down Expand Up @@ -169,7 +169,7 @@ public function testSupportsTheIsEventQlTruePrecondition(): void
$secondEvent,
],
[
new IsEventQlTrue('FROM e IN events PROJECT INTO COUNT() == 0'),
new IsEventQlQueryTrue('FROM e IN events PROJECT INTO COUNT() == 0'),
],
);
}
Expand Down