Here is I have done, but I'm getting {rel : null} for everyuser. I just 
want to return relationship between two nodes if it exists which are two 
users.

User.checkRelationship = function (user, fid, callback) {

  var uids = [user.uid, fid];
  async.map(uids, User.by_uid, function (err, usernodes) {
    if (!err && usernodes && usernodes.length) {
      User.relsCheck(usernodes, function (err, rels) {
        if (!err && rels) {
          console.log('relationship ' + JSON.stringify(rels));
          callback(null, new rels);
        } else {
          callback(err || new Error('friend request exists'));
        }
      });
    } else {
      callback(err || new Error('Unable to fetch user nodes: ' + 
uids.join(',')));
    }
  });
};



User.relsCheck = function (nodes, callback) {
  if (nodes.length !== 2) {
    return callback(new Error('Invalid/insufficient arguments'));
  }
  var query = [
      'START user=node({userId}), other=node({otherId})',
      'MATCH (user) -[rels?:RELTYPE]-> (other)',
      'RETURN rels'
  ].join('\n');


  var params = {
    userId: nodes[0].node().id,
    otherId: nodes[1].node().id,
  };

   db.query(query, params, callback);
};


please help, thanks!

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to