user2580874
user2580874

Reputation: 139

updating multiple properties in Cypher (neo4j)

I cannot update the node using SET for multiple properties in Neo4j, is there any way to handle this?

start n=node:wordindex(word='repine') set     n.wordType = 'rare'         return n

If I want to add n.link = "..." how is that done?

Upvotes: 7

Views: 11128

Answers (3)

Tono Kuriakose
Tono Kuriakose

Reputation: 886

I have an example which i have tried and worked!

Below is the cypher query created the node:

CREATE (n:myAsset {name: 'Test CBP2', Description: 'my test Description', GUID: 'ID000002', Subtype: 'cat-a-cb', Notes: 'my_Notes'  })

I have updated multiple properties by using SET:

MATCH (n:myAsset {GUID: 'ID000002'}) SET n.Description='Updated description',n.Subtype='cat-b-cb', n.Notes='New Notes added' RETURN n

Upvotes: 2

agm1984
agm1984

Reputation: 17132

Here is the newest doc: http://neo4j.com/docs/developer-manual/current/cypher/clauses/set/

 MATCH (n { name: 'Peter' })
 SET n += { hungry: TRUE , position: 'Entrepreneur' }

There are other ways also, so check the docs.

Also check this out if you are doing this from node.js: JSON.Stringify without quotes on properties?

You can use util.inspect() to get an object in like this:

 const util = require('util')

 const params = {
   hungry: TRUE ,
   position: 'Entrepreneur'
 }

 const query = `
   MATCH (n { name: 'Peter' })
   SET n += ${util.inspect(params)}
   RETURN n
 `

Upvotes: 13

Luanne
Luanne

Reputation: 19373

start n=node:wordindex(word='repine')
set n.wordType = 'rare', n.link='link'
return n

should do it

Upvotes: 10

Related Questions