我有下一个查询:
MATCH (dd:Dod)
WHERE dd.name contains 'cu'
WITH collect({displayName:dd.displayName, type: 'Dod',
link: {name: dd.name},
date: apoc.date.format(coalesce(dd.modifiedAt, dd.createdAt))}) as rows1
OPTIONAL MATCH (dn:Dod)<-[:BELONGS_TO]-(nn:Namespace)
WHERE nn.name contains 'cu'
WITH
rows1 + collect({displayName:nn.displayName, type: 'namespace',
link: {name: nn.name, DodName:dn.name},
date: apoc.date.format(coalesce(nn.modifiedAt, nn.createdAt))}) as rows2
OPTIONAL MATCH (de:Dod)<-[:BELONGS_TO]-(ne:Namespace)<-[:BELONGS_TO]-(ee:Edod)
WHERE ee.name contains 'cu'
WITH rows2 + collect({displayName:ee.displayName, type: 'Edod',
link: {name: ee.name, DodName: de.name, namespaceName: ne.name},
date: apoc.date.format(coalesce(ee.modifiedAt, ee.createdAt))}) as rows3
UNWIND rows3 as row
RETURN row
ORDER BY row.date DESC
SKIP 0
LIMIT 10;
在结果中,我得到了所需的值+按组为空(如果未找到Dod /命名空间/ Edod的系统结果) 我需要从row3删除此空值。 我该怎么做?
答案 0 :(得分:1)
您可以在WHERE
语句之前添加RETURN
子句:
UNWIND rows3 as row
WHERE row IS NOT NULL
RETURN row
ORDER BY row.date DESC
SKIP 0
LIMIT 10;