1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fix #2189 - add graph --compact support (#2305)

* fix #2189 - add graph --compact support

* clean code

* fix graph string param escaping

* fix "is not assignable to parameter of type 'GraphClientType'"

* fix README
This commit is contained in:
Leibale Eidelman
2022-11-01 15:45:35 -04:00
committed by GitHub
parent 64f86d6a00
commit 1c6d74ffcb
12 changed files with 713 additions and 77 deletions

View File

@@ -2,34 +2,31 @@
Example usage:
```javascript
import { createClient } from 'redis';
import { createClient, Graph } from 'redis';
const client = createClient();
client.on('error', (err) => console.log('Redis Client Error', err));
await client.connect();
await client.graph.query(
'graph',
"CREATE (:Rider { name: 'Buzz Aldrin' })-[:rides]->(:Team { name: 'Apollo' })"
const graph = new Graph(client, 'graph');
await graph.query(
'CREATE (:Rider { name: $riderName })-[:rides]->(:Team { name: $teamName })',
{
params: {
riderName: 'Buzz Aldrin',
teamName: 'Apollo'
}
}
);
const result = await client.graph.query(
'graph',
`MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Apollo' RETURN r.name, t.name`
const result = await graph.roQuery(
'MATCH (r:Rider)-[:rides]->(t:Team { name: $name }) RETURN r.name AS name',
{
name: 'Apollo'
}
);
console.log(result);
```
Output from console log:
```json
{
headers: [ 'r.name', 't.name' ],
data: [ [ 'Buzz Aldrin', 'Apollo' ] ],
metadata: [
'Cached execution: 0',
'Query internal execution time: 0.431700 milliseconds'
]
}
console.log(result.data); // [{ name: 'Buzz Aldrin' }]
```