Skip to content

Commit

Permalink
fixed typos and extended roadmap
Browse files Browse the repository at this point in the history
  • Loading branch information
transistive committed Dec 8, 2020
1 parent 51eae6a commit 5d584c9
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ $results = $client->runStatements([
The returned value is a vector containing result vectors.

```php
$results->first(); //Contain the first result vector
$results->get(0); //Contain the first result vector
$results->first(); //Contains the first result vector
$results->get(0); //Contains the first result vector
$result->get(1); //Contains the second result vector
```

### Opening a transaction

The `openTransaction` method will start a transaction with over the relevant connection.
The `openTransaction` method will start a transaction over the relevant connection.

```php
use Laudis\Neo4j\Databags\Statement;
Expand Down Expand Up @@ -149,7 +149,7 @@ Wrapping the injections in a callable will enforce lazy initialization.

This client tries to strike a balance between extensibility, performance and clean code. All elementary classes have an interface. These provide infinite options to extend or change the implementation.

This library does use any custom result classes but uses php-ds instead. These data structures are competent, flexible and fast. It furthermore provides a consistent interface and works seamlessly with other iterables.
This library does not use any custom result classes but uses php-ds instead. These data structures are competent, flexible and fast. It furthermore provides a consistent interface and works seamlessly with other iterables.

Flexibility is maintained where possible by making all parameters iterables if they are a container of sorts. This means you can pass parameters as an array, \Ds\Map or any other object which implements the \Iterator or \IteratorAggregate. These examples are all valid:

Expand Down Expand Up @@ -207,13 +207,53 @@ Version 2.0 will have cluster support. There is no concrete API yet.
Version 2.0 will have graph representation suppport. The inteface for this is not yet set in stone, but will be somthing akin to this:

```php
$graph = $client->graphOf('MATCH (x:Article) - [:ContainsReferenceTo] -> (y:Article)');
$client = $clientBuilder->withGraph($client);
$result = $client->run('MATCH (x:Article) - [:ContainsReferenceTo] -> (y:Article)');

$node = $graph->enter(HasLabel::create('Article')->and(HasAttribute::create('slug', 'neo4j-is-awesome')));
$node = $result->getGraph()->enter(HasLabel::create('Article')->and(HasAttribute::create('slug', 'neo4j-is-awesome')))->first();

foreach ($node->relationships() as $relationship) {
if (!$relationship->endNode()->relationships()->isEmpty()) {
echo 'multi level reference detected' . "\n";
echo 'multi level path detected' . "\n";
}
}
```
### Support for statistics

Neo4j has the option to return statement statistics as well. These will be supported in version 2.0 with an api like this:

```php
// This will create a client which will wrap the results and statistics in a single object.
$client = $clientBuilder->withStatistics($client);
$result = $client->run('MERGE (x:Node {id: $id}) RETURN x.id as id', ['id' => Uuid::v4()]);
echo $result->getStatistics()->getNodesCreated() . "\n"; // will echo 1 or 0.
echo $result->getResults()->first()->get('id') . "\n"; // will echo the id generated by the Uuid::v4() method
```

Statistics aggregate like this:

```php
$results = $client->runStatements([
Statement::create('MERGE (x:Node {id: $id}) RETURN x', ['id' => Uuid::v4()]),
Statement::create('MERGE (p:Person {email: $email})', ['email' => '[email protected]'])
]);

$total = Statistics::aggregate($results);
echo $total->getNodesCreated(); // will echo 0, 1 or 2.
```

### Result decoration

Statistics and graph representation are ways of decorating a result. They can be chained like this:

```php
$client = $clientBuilder->withGraph($client);
$client = $clientBuilder->withStatistics($client);

$result = $client->run('MATCH (x:Article) RETURN x.slug as slug LIMIT 1');
$statistics = $result->getStatistics();
$graph = $result->getResults()->getGraph();
$records = $result->getResults()->getResults();
```

This way maximum flexibility is guaranteed. Type safety will be enforced by using psalm templates.

0 comments on commit 5d584c9

Please sign in to comment.