Skip to content
This repository was archived by the owner on Sep 18, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion mage/query-modules/cpp/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,42 @@ MATCH (intern:Intern) CALL node.relationship_types(intern, ["<KNOWS", "SEES>", "
+--------------------------------+
```

### `relationship_exists(node, pattern)`

Checks if given node has a relationship of the pattern.

#### Input:

- `node: Node` ➡ node for which relationship existance is to be verified.
- `pattern: List[string] (optional)` ➡ list of relationship types for which it will be checked if at least one of them exists; if nothing is stated, procedure checks all types of relationships.

:::info

If '<' is added in front of the relationship type, only relationships coming into the node will be checked (e.g., "<KNOWS"), while if '>' is added at the end of the relationship type, only relationships coming from the node will be checked (e.g., "KNOWS>").
Furthermore, if relationship type is not relevant, it is possible to enter only "<" or ">" to check ingoing or outgoing relationships.

:::

#### Output:

- `exists: bool` ➡ whether or not provided node has a relationship of specified type.

#### Usage:

```cypher
MERGE (a:Person {name: "Phoebe"}) MERGE (b:Person {name: "Joey"}) CREATE (a)-[f:FRIENDS]->(b);
MATCH (a:Person {name: "Joey"}) CALL node.relationship_exists(a, ["<FRIENDS"])
YIELD exists RETURN exists;
```

```plaintext
+----------------------------+
| exists |
+----------------------------+
| True |
+----------------------------+
```


### `relationships_exist(node, relationships)`

Expand Down Expand Up @@ -124,4 +160,3 @@ MATCH (h:Human) CALL node.relationships_exist(h, ["LOVES>", "TAKES_CARE_OF", "FO
| {"<LOVES": true, "FOLLOWS": false, "LOVES>": false, "TAKES_CARE_OF": true} |
+----------------------------------------------------------------------------+
```