From ba865e68a77d729f330dd7b94c0de9dfd8358129 Mon Sep 17 00:00:00 2001 From: Dave MacLeod <56599343+Dhghomon@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:39:37 +0900 Subject: [PATCH] Bit more --- .../reference-guide/graph_relations.mdx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/content/doc-surrealdb/reference-guide/graph_relations.mdx b/src/content/doc-surrealdb/reference-guide/graph_relations.mdx index 7ec927f9c..dc90c1134 100644 --- a/src/content/doc-surrealdb/reference-guide/graph_relations.mdx +++ b/src/content/doc-surrealdb/reference-guide/graph_relations.mdx @@ -244,7 +244,27 @@ For further details on this pattern, see [this section](/docs/surrealql/statemen ### Traverse directly from a record instead of using SELECT +As graph traversal takes place between records, the same syntax can be used directly from one or more record IDs without needing to use a `SELECT` statement. +```surql +CREATE ONLY user:mcuserson SET name = "User McUserson"; +CREATE ONLY comment:one SET + text = "I learned something new!", + created_at = time::now(); +CREATE ONLY cat:pumpkin SET name = "Pumpkin"; + +RELATE user:mcuserson->wrote->comment:one SET + location = "Arizona", + os = "Windows 11", + mood = "happy"; + +RELATE user:mcuserson->likes->cat:pumpkin; +``` + +```surql +comment:one<-wrote<-user; +user:mcuserson->likes->cat; +``` ### Graph paths in schemas