kien bui
kien bui

Reputation: 1820

How to add ID node into property and remove a few properties of node in result neo4j?

Node: User{username, password, phone, status} I want to return a User include ID node and exclude password

Example:

NodeID:1 {username:"admin", password: "123456", phone:"0123456567, status: 1"}

Return:

user{id: 1, username:"admin", phone:"0123465567", status: 1}

Upvotes: 0

Views: 244

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30397

You'll either need to specify only the properties you want (including the internal neo4j node id), or use APOC Procedures to remove the properties you don't want from the map.

Here's an example using APOC, after using map projection to get the map of properties from the node and add the id property to the map.

MATCH (u:User{username:'admin'})
WITH u {id:id(u), .*} as u
WITH apoc.map.removeKey(u,'password') as u
RETURN u

Upvotes: 1

Related Questions