How to return Option<_>
when create a record with random ID?
#4073
Answered
by
Dhghomon
HaoYang670
asked this question in
Q&A
-
I am using struct Record {
id: Thing,
}
let record: Vec<Record> = db.create(TABLE_NAME).content(...).await? to insert a record in the table and get the id back. But I want the return type to be |
Beta Was this translation helpful? Give feedback.
Answered by
Dhghomon
Jun 5, 2024
Replies: 1 comment 2 replies
-
Yes, adding .take(0) to the end should do it. There is an example here showing the method in use: https://docs.rs/surrealdb/latest/surrealdb/struct.Response.html#method.take |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Dhghomon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, adding .take(0) to the end should do it. There is an example here showing the method in use: https://docs.rs/surrealdb/latest/surrealdb/struct.Response.html#method.take