Skip to content

Commit

Permalink
Add graph.byElementId function (#752)
Browse files Browse the repository at this point in the history
Co-authored-by: linneaandersson <[email protected]>
  • Loading branch information
JPryce-Aklundh and LinneaAndersson authored Sep 29, 2023
1 parent 5ef0b53 commit b74d23f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
13 changes: 13 additions & 0 deletions modules/ROOT/pages/clauses/use.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,16 @@ The argument can be any expression that evaluates to the name of a constituent g
USE graph.byName($graphName)
MATCH (n) RETURN n
----

[[query-use-examples-query-composite-database-by-element-id]]
=== Query a composite database constituent using elementId

The `graph.byElementId()` function (introduced in Neo4j 5.13), can be used in the `USE` clause to resolve a constituent graph to which a given element id belongs.
In the below example, it is assumed that the DBMS contains a composite database constituent, which contains the element id `4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0`.
If the constituent database is not a standard database in the DBMS an error will be thrown:
.Query
[source, cypher, role=test-skip]
----
USE graph.byElementId("4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0")
MATCH (n) RETURN n
----
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ GRANT LOAD ON ALL DATA TO `role`
| New privilege that controls a user's ability to load data.
Unlike other privileges, these are not granted, denied, or revoked on graphs, databases, or the DBMS, but instead on `ALL DATA`.

a|
label:functionality[]
label:new[]

[source, cypher, role=noheader]
----
USE graph.byElementId(elementId :: STRING)
----

| New graph function, xref:functions/graph.adoc#functions-graph-by-elementid[graph.byElementId()], that resolves the constituent graph to which a given element id belongs.
|===

[[cypher-deprecations-additions-removals-5.12]]
Expand Down
24 changes: 23 additions & 1 deletion modules/ROOT/pages/functions/graph.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,26 @@ RETURN n
Returns all nodes from all graphs on the current composite database.
======
======

[[functions-graph-by-elementid]]
== graph.byElementId()

_This feature was introduced in Neo4j 5.13._

The `graph.byElementId()` function is used in the xref:clauses/use.adoc[] clause to resolve a constituent graph to which a given element id belongs.
If the constituent database is not a standard database in the DBMS, an error will be thrown.

.+graph.byElementId()+
======
In this example, it is assumed that the DBMS contains a composite database constituent, which contains the element id `4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0`.
.Query
[source, cypher, role=test-skip]
----
USE graph.byElementId("4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0")
MATCH (n) RETURN n
----
======
5 changes: 4 additions & 1 deletion modules/ROOT/pages/functions/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,11 @@ Graph functions provide information about the constituent graphs in composite da
[options="header"]
|===
| Function | Signature | Description
1.1+| xref:functions/graph.adoc#functions-graph-by-elementid[`graph.byElementId()`] | `USE graph.byElementId(elementId :: STRING)` | Resolves the constituent graph to which a given element id belongs.
label:new[Introduced in Neo4j 5.13]
1.1+| xref:functions/graph.adoc#functions-graph-byname[`graph.byName()`] | `USE graph.byName(name :: STRING)` | Resolves a constituent graph by name.
1.1+| xref:functions/graph.adoc#functions-graph-names[`graph.names()`] | `graph.names() :: LIST<STRING>` | Returns a list containing the names of all graphs in the current composite database.
1.1+| xref:functions/graph.adoc#functions-graph-names[`graph.propertiesByName()`] | `graph.propertiesByName(name :: STRING) :: MAP` | Returns a map containing the properties associated with the given graph.
1.1+| xref:functions/graph.adoc#functions-graph-byname[`graph.byName()`] | `USE graph.byName(name :: STRING)` | Resolves a constituent graph by name.
|===

[[header-query-functions-database]]
Expand All @@ -767,6 +769,7 @@ Database functions provide information about databases.
|===
| Function | Signature | Description
1.1+| xref:functions/database.adoc#functions-database-nameFromElementId[`db.nameFromElementId()`] | `db.nameFromElementId(name :: STRING) :: STRING` | Resolves the database name from the given element id.
label:new[Introduced in 5.12]
|===

[[header-query-functions-user-defined]]
Expand Down

0 comments on commit b74d23f

Please sign in to comment.