Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@redis/graph

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redis/graph

Example usage: ```javascript import { createClient, Graph } from 'redis';

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
increased by2.49%
Maintainers
1
Weekly downloads
 
Created

What is @redis/graph?

@redis/graph is an npm package that provides a client for interacting with RedisGraph, a graph database module for Redis. It allows you to create, query, and manage graph data structures within a Redis database.

What are @redis/graph's main functionalities?

Creating Nodes and Relationships

This feature allows you to create nodes and relationships in a graph. The code sample demonstrates how to create a person node, a city node, and a relationship between them.

const { createClient } = require('@redis/graph');

async function createGraph() {
  const client = createClient();
  await client.connect();

  const query = `
    CREATE (p:Person {name: 'John Doe', age: 30})
    CREATE (c:City {name: 'New York'})
    CREATE (p)-[:LIVES_IN]->(c)
  `;

  await client.query('myGraph', query);
  await client.disconnect();
}

createGraph();

Querying the Graph

This feature allows you to query the graph to retrieve data. The code sample demonstrates how to match a person node and a city node connected by a relationship and return their names.

const { createClient } = require('@redis/graph');

async function queryGraph() {
  const client = createClient();
  await client.connect();

  const query = `
    MATCH (p:Person)-[:LIVES_IN]->(c:City)
    RETURN p.name, c.name
  `;

  const result = await client.query('myGraph', query);
  console.log(result);
  await client.disconnect();
}

queryGraph();

Updating Nodes and Relationships

This feature allows you to update properties of nodes and relationships in the graph. The code sample demonstrates how to update the age property of a person node.

const { createClient } = require('@redis/graph');

async function updateGraph() {
  const client = createClient();
  await client.connect();

  const query = `
    MATCH (p:Person {name: 'John Doe'})
    SET p.age = 31
  `;

  await client.query('myGraph', query);
  await client.disconnect();
}

updateGraph();

Deleting Nodes and Relationships

This feature allows you to delete nodes and relationships from the graph. The code sample demonstrates how to delete a person node and all its relationships.

const { createClient } = require('@redis/graph');

async function deleteGraph() {
  const client = createClient();
  await client.connect();

  const query = `
    MATCH (p:Person {name: 'John Doe'})
    DETACH DELETE p
  `;

  await client.query('myGraph', query);
  await client.disconnect();
}

deleteGraph();

Other packages similar to @redis/graph

Keywords

FAQs

Package last updated on 20 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc