简体   繁体   English

如何使用变量的 ID 创建记录?

[英]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.

相关问题 如何在存储过程中创建记录和该记录的表? - How Can I Create Record and Table of That Record Within a Stored Procedure? 您好,如何根据 ID 在一列中显示 2 条记录? - Hello, how can I show 2 record in one column based on ID? 如何覆盖从 Odoo 中的另一个 model 创建的记录的 create 方法? - How can I override the create method of a record created from another model in Odoo? 从另一个表中为每条记录创建一条记录并将id设置为该字段 - Create a record for each record from another table and set the id to the field 创建具有ID的记录 - Create record with id 如何检索和使用在RSpec / Capybara测试中创建的记录的ID? - How can I retrieve and use the ID of a record I've created inside an RSpec/Capybara test? 如何使用 integer id 变量在数据库中搜索? - How can I search in a database using an integer id variable? 我如何附加一个新的 id 来记录 - How do I append a new id to record 如何使用来自 Java 字符串变量的参数在我的 SQLite 数据库中创建一个新表? - How can I create a new table in my SQLite Database using a param from a Java String variable? 如何创建自动增量ID列? - How can I create auto incremental id column?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM