cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Need Help in Unwind Query

Hi,

I need to know, how can get all the matching records and non matching record by passing query params from nodejs.

i want result something like if file exists then

[{
   name: 'p1.pdf',
   exist: true
},
{
   name: 'p2.pdf',
   exist: true
},
{
   name: 'p3.pdf',
   exist: false
}
]
   unwind [{name: 'p1.pdf' },{name: 'p2.pdf'} , {name: 'p3.pdf'}] as r		
   match (f:file) where f.name = r.name
   return collect({name: f.name, exist: exists(f.name)})

for 3 records it should 3 records only. else i have to loop one by one via nodejs.

I don't know how to return item which are not matched in neo4j. could anyone please explain and guide?

Regards
Meet

1 ACCEPTED SOLUTION

Ah.. typo mistake

unwind $clist as c match(n:file) With Case when c in collect(distinct n.name) Then c+' exists' else c+' does not exist' end as rlist return collect(rlist)

View solution in original post

5 REPLIES 5

intouch_vivek
Graph Steward

Hi @sumitsinghbhavra,

Try below
:param clist =>['a','b','x','y']
unwind $clist as c match(n:file) return Case when c in collect(distinct n.name) Then c+' exists' else c+' does not exist' end

thanks vivek. it not giving me array of objects

unwind $clist as c match(n:file) return With Case when c in collect(distinct n.name) Then c+' exists' else c+' does not exist' end as rlist return collect(rlist)

its not working. giving error because of 2 returns

Ah.. typo mistake

unwind $clist as c match(n:file) With Case when c in collect(distinct n.name) Then c+' exists' else c+' does not exist' end as rlist return collect(rlist)