You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
* 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:
@@ -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' }]
|
||||
```
|
||||
|
Reference in New Issue
Block a user