Hi, now I know this must be simple and I have Googled and searched the forum but I am struggling the responses that I have come across, been looking at this too.
What I am trying to
MATCH (mig:Process)-[rel:SUB_PROCESS|SPECIAL_PROCESS]-(process:Process {name: "Source"})-[state:QUEUED]->(entity:Entity)
This is start of my query. I am getting all processes of a specific type 'Source' that have entities whose current state is QUEUED.
WITH process, collect(entity) as entities
RETURN {p:process, e:entities}
Now this gives me almost the result that I want in that I get my process as the root of result and all of the associated entities nested beneath it
{
{
"p": {
"identity": 520,
"labels": [
"Process"
],
"properties": {
"name": "Source"
}
},
"e": [
{
"identity": 418,
"labels": [
"EntityProcess",
"Entity"
],
"properties": {
"name": "IdentityVerificationCertificateAddress",
"id": "345"
}
},
etc, etc,
}
What I now need to do is to also return the 'state' in my results BUT nested under each individual entity so. I have tried this
RETURN {p:process, e:collect(entity), s:collect(state)}
But obviously this doesnt work as it just gives me a collection of state at the same level as entity.
There is probably some sort of sub query or something I am missing but I just cant get my head around it, can anyone help?
This should be as simple as
process
- entity
- state
- state
- state
- entity
- state
...