diff --git a/src/content/doc-surrealql/datamodel/idioms.mdx b/src/content/doc-surrealql/datamodel/idioms.mdx index 9cb2d95ed..ac7b56c62 100644 --- a/src/content/doc-surrealql/datamodel/idioms.mdx +++ b/src/content/doc-surrealql/datamodel/idioms.mdx @@ -1368,12 +1368,12 @@ person:you ] ``` -As these three use their own algorithms to follow a path, any attempt to construct your own path using `.@` will result in an error. +As these three methods use their own algorithms to follow a path, any attempt to construct your own path using `.@` will result in an error. For example, choosing `+path` along with a field `connections: ->knows->person.@` will return an error because `+path` on its own will use its own recursive planner to output every possible path as an array of arrays, while `->knowns->person.@` is an instruction to put together arrays of each record and the next result from the `->knows->person` path at any possible depth. ```surql -person:1.{..+path}.{ +person:you.{..+path}.{ id, - next: ->knows->person.@ + connections: ->knows->person.@ }; ``` @@ -1381,6 +1381,40 @@ person:1.{..+path}.{ 'Can not construct a recursion plan when an instruction is provided' ``` +Here is the output of both of these queries at a single depth to show the difference in output. + +```surql +person:you.{..1}.{ + id, + connections: ->knows->person.@ +}; + +person:you.{..1+path}->knows->person; +``` + +```surql title="Output" +-------- Query -------- + +{ + connections: [ + person:friend2, + person:friend1 + ], + id: person:you +} + +-------- Query -------- + +[ + [ + person:friend2 + ], + [ + person:friend1 + ] +] +``` + ## Combining Idiom Parts Idioms can combine multiple parts to navigate complex data structures seamlessly.