veliovgroup / ostrio-Neo4jreactivity

Meteor.js Neo4j database reactivity layer
https://atmospherejs.com/ostrio/neo4jreactivity
BSD 3-Clause "New" or "Revised" License
51 stars 5 forks source link

Meteor.neo4j.query keeps returning the same result #49

Closed BenjaminHolland10 closed 9 years ago

BenjaminHolland10 commented 9 years ago

I'm writing a query that matches a node with two properties except when I call the query it returns the same result multiple times. I know I'm passing in different id's and it actually returns different results if I change the Match variable( the a in (a:User)) but I don't know why its not returning the correct results all the time. I've tested the query in the console and it works.Here's my function and the results.

screen shot 2015-06-25 at 6 44 45 pm

screen shot 2015-06-25 at 6 42 58 pm

BenjaminHolland10 commented 9 years ago

As you can see the user input variable is different.

dr-dimitru commented 9 years ago

@BenjaminHolland10 Hi, do you ever tried to query like this:

MATCH (b:User {id: {id}, registered: {registered}}) RETURN b

Could you please try the query I'm suggested above, and let me know about results.

BenjaminHolland10 commented 9 years ago

Yeah that was my first attempt at it. I just tried it again just to make sure and the problem persisted. screen shot 2015-06-25 at 7 01 19 pm screen shot 2015-06-25 at 7 01 36 pm

BenjaminHolland10 commented 9 years ago

This is the function that calls it just for reference. Don't think it has an effect. screen shot 2015-06-25 at 7 06 21 pm

dr-dimitru commented 9 years ago

Just to confirm, please do:

  1. console.log(error, data);
  2. Run same code on both server and client, with same log as above
  3. On server try to run query inside: Meteor.N4JDB.query(...);
BenjaminHolland10 commented 9 years ago

First two are registered last one is not.

screen shot 2015-06-25 at 7 20 00 pm

dr-dimitru commented 9 years ago

@BenjaminHolland10 inside of Meteor.N4JDB.query(...); run console.log(error, data); without b property. And what about client side? Same result?

BenjaminHolland10 commented 9 years ago

Client screen shot 2015-06-25 at 7 34 40 pm code: (N4JDB was giving me a undefined method error) screen shot 2015-06-25 at 7 35 55 pm

Server screen shot 2015-06-25 at 7 25 58 pm code: screen shot 2015-06-25 at 7 26 12 pm

BenjaminHolland10 commented 9 years ago

N4JDB will work in my case just thought i'd let you know and document it for any other user facing the problem.

BenjaminHolland10 commented 9 years ago

What would be the best way to access the data returned by the N4JDB query? @dr-dimitru

dr-dimitru commented 9 years ago

Same as in Meteor.neo4j.query(), last argument is callback with error and data. In data you should have raw data from Neo4j.

BenjaminHolland10 commented 9 years ago

I'm sorry I'm pretty new to Javascript but when I try return the data from the callback it the return value is undefined. This probably has something to do with scope but I'm not sure. Here's what I have right now. screen shot 2015-06-25 at 8 36 24 pm

dr-dimitru commented 9 years ago

@BenjaminHolland10 you're fine. I'm sure there is no data[0], so just console.log(data);, then construct your logic statement based on what returned from database in different cases.

BenjaminHolland10 commented 9 years ago

It's not parsing the data I'm having trouble with It's actually getting the data out of the callback into the outer function. Thank you so much for responding.

dr-dimitru commented 9 years ago

Yes, Meteor.N4JDB works directly with Neo4j DB and returns data as it is presented in Neo4j. Then Meteor.neo4j parce and presents data in Mongo-like way used basically in Meteor

BenjaminHolland10 commented 9 years ago

http://stackoverflow.com/questions/28945481/javascript-callback-returns-undefined-using-neo4j-and-meteor This is my question

dr-dimitru commented 9 years ago

Okay, I see the right answer, if you prefer to work with data on server side. I believe in your case better to work with Neo4j as collection and publish/subscribe way. See this example.

BenjaminHolland10 commented 9 years ago

Thanks for the advice. I have to rewrite a lot of my app but working the publish/subscribe way it a lot cleaner and easier to write.