thingdom / node-neo4j

[RETIRED] Neo4j graph database driver (REST API client) for Node.js
Apache License 2.0
925 stars 135 forks source link

Params doesn't seem to work when passing inside WHERE query #215

Open nabilzhafri opened 7 years ago

nabilzhafri commented 7 years ago

Hi, when I query using attribute filter, it'll work fine. For example:

const query = [
   'MATCH (user:User {email: {email}})',
   'RETURN user'
].join('\n')

const params = {
   email: 'user@example.com' // assume email exists
}

But when I passed inside WHERE statement, it doesn't seem to work:

const query = [
   'MATCH (user:User)',
   'WHERE email = {email}',
   'RETURN user'
].join('\n')

const params = {
   email: 'user@example.com' // assume email exists
}

I needed this because I need to create query to find node by id. At the moment, my workaround is to concat directly to the query, which is not recommended:

const query = [
   'MATCH (user:User)',
   'WHERE id(user) = ' + id,
   'RETURN user'
].join('\n')

Just wondering is this behavior expected? Because I read the documentation this should be supported. Refer: http://neo4j.com/docs/developer-manual/current/cypher/syntax/parameters/