Skip to content

Commit 67752ec

Browse files
authored
Merge pull request #1 from laudis-technologies/testing
Testing
2 parents 51eae6a + 51b09bb commit 67752ec

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

Jenkinsfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,5 @@ pipeline {
3030
sh 'docker-compose -f docker/docker-compose-php-7.4.yml run client php vendor/bin/phpunit'
3131
}
3232
}
33-
stage('Deploy') {
34-
steps {
35-
echo 'Deploying....'
36-
}
37-
}
3833
}
3934
}

README.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ $results = $client->runStatements([
8080
The returned value is a vector containing result vectors.
8181

8282
```php
83-
$results->first(); //Contain the first result vector
84-
$results->get(0); //Contain the first result vector
83+
$results->first(); //Contains the first result vector
84+
$results->get(0); //Contains the first result vector
8585
$result->get(1); //Contains the second result vector
8686
```
8787

8888
### Opening a transaction
8989

90-
The `openTransaction` method will start a transaction with over the relevant connection.
90+
The `openTransaction` method will start a transaction over the relevant connection.
9191

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

150150
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.
151151

152-
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.
152+
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.
153153

154154
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:
155155

@@ -207,13 +207,53 @@ Version 2.0 will have cluster support. There is no concrete API yet.
207207
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:
208208

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

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

214215
foreach ($node->relationships() as $relationship) {
215216
if (!$relationship->endNode()->relationships()->isEmpty()) {
216-
echo 'multi level reference detected' . "\n";
217+
echo 'multi level path detected' . "\n";
217218
}
218219
}
219220
```
221+
### Support for statistics
222+
223+
Neo4j has the option to return statement statistics as well. These will be supported in version 2.0 with an api like this:
224+
225+
```php
226+
// This will create a client which will wrap the results and statistics in a single object.
227+
$client = $clientBuilder->withStatistics($client);
228+
$result = $client->run('MERGE (x:Node {id: $id}) RETURN x.id as id', ['id' => Uuid::v4()]);
229+
echo $result->getStatistics()->getNodesCreated() . "\n"; // will echo 1 or 0.
230+
echo $result->getResults()->first()->get('id') . "\n"; // will echo the id generated by the Uuid::v4() method
231+
```
232+
233+
Statistics aggregate like this:
234+
235+
```php
236+
$results = $client->runStatements([
237+
Statement::create('MERGE (x:Node {id: $id}) RETURN x', ['id' => Uuid::v4()]),
238+
Statement::create('MERGE (p:Person {email: $email})', ['email' => '[email protected]'])
239+
]);
240+
241+
$total = Statistics::aggregate($results);
242+
echo $total->getNodesCreated(); // will echo 0, 1 or 2.
243+
```
244+
245+
### Result decoration
246+
247+
Statistics and graph representation are ways of decorating a result. They can be chained like this:
248+
249+
```php
250+
$client = $clientBuilder->withGraph($client);
251+
$client = $clientBuilder->withStatistics($client);
252+
253+
$result = $client->run('MATCH (x:Article) RETURN x.slug as slug LIMIT 1');
254+
$statistics = $result->getStatistics();
255+
$graph = $result->getResults()->getGraph();
256+
$records = $result->getResults()->getResults();
257+
```
258+
259+
This way maximum flexibility is guaranteed. Type safety will be enforced by using psalm templates.

0 commit comments

Comments
 (0)