From 4cfad3dab23ced5c5733b74b291df0e543243751 Mon Sep 17 00:00:00 2001 From: Jay Koontz Date: Tue, 25 Oct 2022 06:20:55 -0500 Subject: [PATCH] Update RedisGraph README.md (#2239) * Update README.md Simple example using Cypher to CREATE a graph with relationships and then MATCH on that graph * Update README.md Co-authored-by: Leibale Eidelman --- packages/graph/README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/graph/README.md b/packages/graph/README.md index 420d18851d..595e0226b2 100644 --- a/packages/graph/README.md +++ b/packages/graph/README.md @@ -1 +1,35 @@ # @redis/graph + +Example usage: +```javascript +import { createClient } 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 result = await client.graph.query( + 'graph', + `MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Apollo' RETURN r.name, t.name` +); + +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' + ] +} +```