From 422c2874a731b6378d5a684d57813555fe2b1173 Mon Sep 17 00:00:00 2001 From: Josip Mrden Date: Mon, 24 Feb 2025 14:16:32 +0100 Subject: [PATCH 1/2] Add documentation for dynamic node labels within list --- pages/querying/expressions.mdx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pages/querying/expressions.mdx b/pages/querying/expressions.mdx index c749d5b5b..e22aa9634 100644 --- a/pages/querying/expressions.mdx +++ b/pages/querying/expressions.mdx @@ -54,6 +54,9 @@ MATCH (n:$label) RETURN n; ``` +The parameters supported for this syntax are `String` and `List[String]`, meaning that the parameter can have multiple +labels to be assigned to the node. + Using parameters as property maps is partially supported, it isn't supported in `MATCH` nor `MERGE` clause. For example, the following query is illegal: @@ -109,6 +112,25 @@ session.run('CREATE (alice:Person {name: $0, age: $1})', To use parameters with some other driver, please consult the appropriate documentation. +## Dynamic node labels creation + +Memgraph supports creation of node labels using expressions which are of type `String` +or `List[String]`. +The following query will result in the creation of a node label `Foo`: + +``` +WITH {label: "Foo"} as var +CREATE (:var.label); +``` + +while the following query will result in the creation of node labels `Foo` and `Bar`. + +``` +WITH {labels: ["Foo", "Bar"]} as var +CREATE (:var.labels); +``` + + ## CASE Conditional expressions can be expressed in the Cypher language with the `CASE` From b507d778bf9bfcbe5a5b842f7fb81cb3171b6bce Mon Sep 17 00:00:00 2001 From: katarinasupe Date: Tue, 11 Mar 2025 10:11:41 +0100 Subject: [PATCH 2/2] update wording --- pages/querying/expressions.mdx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pages/querying/expressions.mdx b/pages/querying/expressions.mdx index e22aa9634..11d1fb45b 100644 --- a/pages/querying/expressions.mdx +++ b/pages/querying/expressions.mdx @@ -54,8 +54,8 @@ MATCH (n:$label) RETURN n; ``` -The parameters supported for this syntax are `String` and `List[String]`, meaning that the parameter can have multiple -labels to be assigned to the node. +This syntax supports parameters of type `String` and `List[String]`, allowing a +node to have one or multiple labels assigned. Using parameters as property maps is partially supported, it isn't supported in `MATCH` nor `MERGE` clause. For example, the following query is illegal: @@ -114,9 +114,10 @@ documentation. ## Dynamic node labels creation -Memgraph supports creation of node labels using expressions which are of type `String` -or `List[String]`. -The following query will result in the creation of a node label `Foo`: +Starting from version 3.1, Memgraph allows node labels to be created using +expressions of type `String` or `List[String]`. + +For example, the following query will create a node with the label `Foo`: ``` WITH {label: "Foo"} as var