GithubHelp home page GithubHelp logo

ioredisgraph's Introduction

Libraries.io dependency status for latest release Node CI npm version

ioredisgraph

A javascript client for RedisGraph based on the excellent ioredis client.

Literally based off ioredis. This module wraps ioredis, adds a couple commands, and returns an array of objects from each query (as well as the query meta information).

let RedisGraph = require('ioredisgraph');

async function demo () {
  let graph = new RedisGraph('MotoGP')
  await graph.query("CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})")
  let ridingForYamaha = await graph.query("MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r,t")

  console.log(ridingForYamaha)
  // [ { 'r.name': 'Valentino Rossi', 't.name': 'Yamaha' },
  // meta: { queryInternalExecutionTime: '1.446600 milliseconds' } ]

  await graph.delete()
}

demo()

Usage

Constructor

ioredisgraph has all the same constructor options as ioredis, but adds a graphName argument.

Add graph name as first argument to constructor:

let graph = new RedisGraph('DEMO_GRAPH')

let graph = new RedisGraph('DEMO_GRAPH', 6379)

or add to options object:

let graph = new RedisGraph({graphName: 'DEMO_GRAPH', port: 6379})

Methods

These methods are added. All other methods usually available to an ioredis client are accessible.

graph.query(cypherString) Pass in a string for your cypher query. Results are an array of object. Each object has properties based on the name used in the query. access results.meta for the meta information redisgraph returns.

graph.delete() Deletes database

graph.explain(cypherString)

Performance

RedisGraph supports a special --compact argument on queries, which improves performance by having responses include enums instead of looking up the string values for property names, label names, and relationship type names. This client does not use --compact currently. Create an issue to support this, we are currently waiting for a solution to redis/ioredis#895

ioredisgraph's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ioredisgraph's Issues

RedisGraph 2.0

Hi @Jonahss
Thanks for the work on this project!
We are about to officially release 2.0, so I just wanted to give heads up. We had a slight modification on 1.99.7 which changed to the index modifications commands responses.
In case you have any questions, you can reach me at our repo issues page or directly by mail.
Cheers!
Dvir

following the readme gets a type exception

contents of ioredisgraph.js is cut and paste from the readme

node ioredisgraph.js 

(node:7686) UnhandledPromiseRejectionWarning: TypeError: result.map is not a function
    at resultSet.map (/Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredisgraph/index.js:28:25)
    at Array.map (<anonymous>)
    at /Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredisgraph/index.js:27:29
    at Command.transformReply (/Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredis/built/command.js:238:22)
    at Command.value [as resolve] (/Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredis/built/command.js:218:30)
    at DataHandler.returnReply (/Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredis/built/DataHandler.js:67:26)
    at JavascriptRedisParser.returnReply (/Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredis/built/DataHandler.js:21:22)
    at JavascriptRedisParser.execute (/Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:544:14)
    at Socket.DataHandler.redis.stream.on.data (/Users/renewooller/software/mono/backend/nl-tune-yards/node_modules/ioredis/built/DataHandler.js:25:20)
    at Socket.emit (events.js:182:13)
(node:7686) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7686) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
node --version
v10.9.0

output of redis monitor:

OK
1564965631.742714 [0 172.17.0.1:45284] "info"
1564965631.746975 [0 172.17.0.1:45284] "GRAPH.QUERY" "MotoGP" "CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})"

Please improve docs re: graphql server objective (CRUD, parameters, dataloader/batch get) #28

Hi, I want to use this for a GraphQL project but I'm unclear how do you specify the endpoint in docker compose ... and I get ECONNREFUSED when I use it like works with ioredis constructor;

Could you add a link to or list of the options for the RedisGraph constructor to the readme?

Also, to prevent query injections, it's critical to use parameters not string formatting. How do you do CRUD operations with ioredisgraph with query parameters?

How do you override the id in a CREATE query to use uuid or oauth2 user sub?

Another thought, how do you integrate this with Dataloader? We just need a function keys => get(keys)

Thanks in advance, look forward to watch / use this project,
Bionicles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.