Search code examples
memgraphdb

How can I check if a node has a label?


I didn't fid a way how to check if a node has a label. I've found the documentation for HasLabel but this is related to graph output and visualization (https://memgraph.com/docs/data-visualization/graph-style-script/built-in-elements#haslabelnode-label). I need it for my Cypher query.


Solution

  • I think you can use label.exists function.

    Query will look like:

    MATCH (n) WHERE label.exists(n, "Person") RETURN n;