Skip to content
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

GraphDatabase instance does not have access to functions #200

Open
ayhid opened this issue May 14, 2016 · 9 comments
Open

GraphDatabase instance does not have access to functions #200

ayhid opened this issue May 14, 2016 · 9 comments

Comments

@ayhid
Copy link

ayhid commented May 14, 2016

I am testing the module within a meteor app, but I can't get further from instanciating the GraphDatabase Class.

const neo4j = require('neo4j');
const GraphDB =  new neo4j.GraphDatabase('http://neo4j:neo4j@localhost:7474');

//getting this object
{ 
  url: 'http://neo4j:neo4j@localhost:7474',
  auth: { username: 'neo4j', password: 'neo4j' },
  headers: { 'User-Agent': 'node-neo4j/2.0.0-RC2' },
  proxy: undefined,
  agent: undefined 
}

As you can see I can't call any methods on this object as it does contain none.

Am I missing something?

@aseemk
Copy link
Member

aseemk commented May 14, 2016

I'm not sure. =) What do you mean by "getting this object"? How are you printing that? Have you tried actually calling the methods in the documentation?

As is typical for JS classes, all methods are actually defined on the class's prototype. So perhaps you're just not seeing prototype methods depending on how you're printing that object.

Try following the documentation. Let me know if anything doesn't work. Hope that helps for now.

@ayhid
Copy link
Author

ayhid commented May 15, 2016

@aseemk I actually tried to call the query() method first but I got an exception TypeError: undefined is not a function, than I used a simple console.log() to print out my GraphDB object and see whether or not it contains some methods.

@royipressburger
Copy link

Maybe you are mistaken GraphDB.query () with GraphDB.cypher () because query is really no a function on the db object

@ayhid
Copy link
Author

ayhid commented May 15, 2016

@royipressburger you are right I was calling GraphDB.query() instead of GraphDB.cypher()

Now I am having another error here is what I am calling:

GraphDB.cypher({
  query: 'MATCH (n) RETURN n',
  params: {},
  },
 callback
);

And I am getting this error:

TypeError: Object [object Object] has no method 'http' at GraphDatabase.module.exports.GraphDatabase.cypher (/node_modules/neo4j/lib-new/GraphDatabase.js:208:19)

@royipressburger
Copy link

@ayhid for me its abit hard to understand like that, Can you add the complete stacktrace and more code please?

@ayhid
Copy link
Author

ayhid commented May 16, 2016

@royipressburger thank you for your patience

here is what I am actually doing

const neo4j = require('neo4j');
const GraphDB = new neo4j.GraphDatabase('http://neo4j:neo4j@localhost:7474');
function callback(err, results) {
    console.log('callback');
    if (err) throw err;
    var result = results[0];
    if (!result) {
        console.log('No user found.');
    } else {
        var user = result;
        console.log(user);
    }
};

Meteor.methods({
    'graph.get': ()=> {
        GraphDB.cypher({
                query: 'MATCH (n) RETURN n',
                params: {},
            },

            callback
        );
    }
})

and here is the error with the full stack trace

TypeError: Object [object Object] has no method 'http'
    at GraphDatabase.module.exports.GraphDatabase.cypher (/node_modules/neo4j/lib-new/GraphDatabase.js:208:19)
    at [object Object].artistGet (imports/api/server/artists/methods.js:22:17)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
    at packages/ddp-server/livedata_server.js:1617:18
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at Server.apply (packages/ddp-server/livedata_server.js:1616:45)
    at Server.call (packages/ddp-server/livedata_server.js:1559:17)
    at [object Object]:1:-54
    at Script.(anonymous function) [as runInThisContext] (vm.js:41:22)
    at .meteor/local/build/programs/server/shell-server.js:366:27

@royipressburger
Copy link

royipressburger commented May 16, 2016

@ayhid Hi again.

So i just copied your code and ran it, everything looks Ok there..
The thing is I did not wrap it with Meteor.methods, so i guess the problem is there somewhere..
I don't know Meteor so I'm sorry I cant help :\

UPDATE:
when looking at GraphDatabase.js source code I see nothing related to the http method..
So maybe try to delete the node modules and rerun npm install? i doute it will work though

@ayhid
Copy link
Author

ayhid commented Jun 6, 2016

@royipressburger sorry for the delay, I have the 2.0.0-RC2 version and the GraphDatabase.js calls a http method

@ekkis
Copy link

ekkis commented Jun 10, 2016

I'm having the same issue with the same version. I posted here before coming across this issue: #204 - though I should say that the .cypher() method does seem to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants