Skip to content

close #43. Changed graph creation and docs. #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const redis = require("redis"),
* RedisGraph client
*/
class Graph {
/**
* Creates a client to a specific graph running on the specific host/post
* See: node_redis for more options on createClient
*
* @param {string} graphId the graph id
* @param {string | RedisClient} [host] Redis host or node_redis client
* @param {string} [port] Redis port
* @param {ClientOpts} [options] node_redis options
*/
/**
* Creates a client to a specific graph running on the specific host/post
* See: node_redis for more options on createClient
*
* @param {string} graphId the graph id
* @param {string | RedisClient} [host] Redis host or node_redis client
* @param {string | int} [port] Redis port
* @param {ClientOpts} [options] node_redis options
*/
constructor(graphId, host, port, options) {
this._graphId = graphId; // Graph ID
this._labels = []; // List of node labels.
Expand All @@ -29,7 +29,7 @@ class Graph {
let client =
host instanceof redis.RedisClient
? host
: redis.createClient.apply(redis, [].slice.call(arguments, 1));
: redis.createClient(port, host, options);
this._sendCommand = util.promisify(client.send_command).bind(client);
}

Expand Down
17 changes: 15 additions & 2 deletions test/redisGraphAPITest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@ describe("RedisGraphAPI Test", () => {
return api.deleteGraph().catch(() => {});
});

it("test bring your client", () => {
return new RedisGraph("social", redis.createClient());
it("test connection from post and host", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DvirDukhan "post"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// Assuming this test is running against localhost:6379 with no password.
let graph = new RedisGraph("social", "127.0.0.1", 6379, {password:undefined});
let result = await graph.query("CREATE ({name:'roi', age:34})");
assert.ok(!result.hasNext());
assert.equal(1, result.getStatistics().nodesCreated());
graph.deleteGraph();
})

it("test connection from client", async () => {
let graph = new RedisGraph("social", redis.createClient());
let result = await graph.query("CREATE ({name:'roi', age:34})");
assert.ok(!result.hasNext());
assert.equal(1, result.getStatistics().nodesCreated());
graph.deleteGraph();
});

it("test Create Node", async () => {
Expand Down