From ae62e27927c8f45874d54332f2e861e7ca869480 Mon Sep 17 00:00:00 2001 From: Dave MacLeod <56599343+Dhghomon@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:28:48 +0900 Subject: [PATCH] Mention that +shortest can also take a parameter --- src/content/doc-surrealql/datamodel/idioms.mdx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/content/doc-surrealql/datamodel/idioms.mdx b/src/content/doc-surrealql/datamodel/idioms.mdx index 4f16341d5..c1636e95f 100644 --- a/src/content/doc-surrealql/datamodel/idioms.mdx +++ b/src/content/doc-surrealql/datamodel/idioms.mdx @@ -1277,6 +1277,14 @@ person:you.{..+shortest=person:star}->knows->person; ] ``` +The part after `+shortest` can also take a parameter if it is a record ID. The following example will return the same result as the previous one. + +```surql +LET $you = SELECT VALUE id FROM ONLY person WHERE name = 'you' LIMIT 1; +LET $star = SELECT VALUE id FROM ONLY person WHERE name = 'star' LIMIT 1; +$you.{..+shortest=$star}->knows->person; +``` + #### +collect Using `+collect` will collect all of the unique collected records. As this collection is created by moving recursively one level at a time, the output will show the closest connections first and least close connections at the end.