[英]How can I create a record with an ID from a variable?
I'm trying to create a record in SurrealQL with a variable:我正在尝试使用变量在 SurrealQL 中创建记录:
CREATE student:$name SET age = 38
but for some reason the syntax isn't allowed.但由于某种原因,不允许使用该语法。 Any idea why this is the case?
知道为什么会这样吗?
CREATE type::thing("student", $name) SET age 38
https://surrealdb.com/docs/surrealql/functions/type#thing covers this, but you can use a type function to create a record link, which in your case can be passed to CREATE. https://surrealdb.com/docs/surrealql/functions/type#thing涵盖了这一点,但您可以使用类型 function 创建记录链接,在您的情况下可以将其传递给 CREATE。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.