You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/advanced_query_operations.rst
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ As discussed in the note above, this is for example useful when you need to orde
60
60
61
61
Options for `intermediate_transform` *variables* are:
62
62
63
-
- `source`: `string`or `Resolver` - the variable to use as source for the transformation. Works with resolvers (see below).
63
+
- `source`: `string`or `Resolver` - the variable to use as source for the transformation. Works with resolvers (see below).
64
64
- `source_prop`: `string` - optionally, a property of the source variable to use as source for the transformation.
65
65
- `include_in_return`: `bool` - whether to include the variable in the return statement. Defaults to False.
66
66
@@ -95,7 +95,7 @@ Subqueries
95
95
The `subquery` method allows you to perform a `Cypher subquery <https://neo4j.com/docs/cypher-manual/current/subqueries/call-subquery/>`_ inside your query. This allows you to perform operations in isolation to the rest of your query::
96
96
97
97
from neomodel.sync_match import Collect, Last
98
-
98
+
99
99
# This will create a CALL{} subquery
100
100
# And return a variable named supps usable in the rest of your query
101
101
Coffee.nodes.filter(name="Espresso")
@@ -106,12 +106,18 @@ The `subquery` method allows you to perform a `Cypher subquery <https://neo4j.co
106
106
)
107
107
.annotate(supps=Last(Collect("suppliers"))),
108
108
["supps"],
109
+
[NodeNameResolver("self")]
109
110
)
110
111
112
+
Options for `subquery` calls are:
113
+
114
+
- `return_set`: list of `string` - the subquery variables that should be included in the outer query result
115
+
- `initial_context`: optional list of `string` or `Resolver` - the outer query variables that will be injected at the begining of the subquery
116
+
111
117
.. note::
112
-
Notice the subquery starts with Coffee.nodes ; neomodel will use this to know it needs to inject the source "coffee" variable generated by the outer query into the subquery. This means only Espresso coffee nodes will be considered in the subquery.
118
+
In the example above, we reference `self` to be included in the initial context. It will actually inject the outer variable corresponding to `Coffee` node.
113
119
114
-
We know this is confusing to read, but have not found a better wat to do this yet. If you have any suggestions, please let us know.
120
+
We know this is confusing to read, but have not found a better way to do this yet. If you have any suggestions, please let us know.
0 commit comments