I'm trying out Structr, which seems great, but I'm running into an issue where I want to loop through a returned collection and output an html element for each item in it. It's a little complicated by the fact that I also need to use merge_unique on the collection before I do so, because the old version of neo4j Structr uses chokes on a combination of optional match and collect(distinct n).
Here's the request I'm making in the cypher query pane of Structr:
MATCH (c:Country) WHERE c.code = 'US'
Optional match (c)<-[:THING_IN]-(t:Thing)-[:THING_BELONGS_TO]-(p:Project)
optional match (p)<-[:SPONSORS]-(sp)
where p.status = "ACTIVE"
with c, collect(distinct p) as projects, collect(sp.name) as sponsors
RETURN {
name:c.name,
code:c.code,
open_projects:size(filter(x IN projects WHERE x.status = "ACTIVE")),
closed_projects:size(filter(x IN projects WHERE x.status <> "ACTIVE")),
all_projects:size(projects),
sponsors:sponsors
}
So, "sponsors" is returned as a non-distinct collection of all the names of the sponsors of the projects. It works to then loop through the sponsors if they're returned as objects, and display ${sponsor.name} (after creating a data-binding with sponsor = merge_unique(data.sponsors), but I can't just display each sponsor from a collection of string variables.
I'm not sure I'm explaining this very well, but if you've used Structr, I expect this is a problem you've run into. If you can point me in the right direction, thanks in advance.