Return all nodes properties

Hi,

I'm an early begginer in Neo4j and i need some help with the return syntax.

I want to return all nodes properties but i'm not able to get them without null values and repeated nodes.

This is how i create it.

CREATE (a: Formulario {Nombre:'PS2115'})
CREATE (b: Datos_Internos {Autor:'Sergio', Fecha:'07/02/2022', Identificador:'847', Revision:'3', Descripcion:'Una descripcion bonita'})
CREATE (c: Datos_Cliente {Nombre:'Igeteam', Direccion:'Parque Tecnologico'})
CREATE (d: Persona_Contacto {Nombre:'Gerente', Telefono:'654789321', Email:'Gerente@gamil.com', Cargo:'Gerente'})

CREATE (a)-[:Datos]->(b)
CREATE (a)-[:Datos]->(c)
CREATE (c)-[:Contacto]->(d)

And this is the resulting graph.

image

Now i am trying to return the properties and values of the nodes.

MATCH (f:Formulario{Nombre:'PS2115'})-[:Datos]->(c)
OPTIONAL MATCH(c)-[:Contacto]->(d)
WITH f,c,d
RETURN{Proyecto: properties(f), Datos: properties(c), Persona_Contacto: properties(d)}

image

I want to know if it is possible to get only one message with all the information of the nodes properties.

Thanks!!

@sfuertes

If possible, you could use the Apoc procedures, in particular this one apoc.map.merge - APOC Extended Documentation (or maybe also the apoc.map.mergeList - APOC Extended Documentation if you have a lot of maps)

MATCH (f:Formulario{Nombre:'PS2115'})-[:Datos]->(c)
OPTIONAL MATCH(c)-[:Contacto]->(d)
WITH f,c,d
RETURN apoc.map.merge( apoc.map.merge(properties(f), properties(c)), properties(d))

If you want them collected and don't care which Persona_Contracto is associated with which Datos.

MATCH (f:Formulario{Nombre:'PS2115'})-[:Datos]->(c)
OPTIONAL MATCH(c)-[:Contacto]->(d)
WITH f, collect(properties(c)) as datos, collect(properties(d)) as persona_contacto
RETURN{Proyecto: properties(f), Datos: datos, Persona_Contacto: persona_contacto}

If you want to the persona_contacto associated with its dates (query assumes zero or one d nodes per c node, and I didn't know what to call label XX):

MATCH (f:Formulario{Nombre:'PS2115'})-[:Datos]->(c)
CALL {
WITH c
OPTIONAL MATCH(c)-[:Contacto]->(d)
RETURN {datos: properties(c), persona_contacto: properties(d)} as datos
}
RETURN{Proyecto: properties(f), XX: collect(datos)}