Several ways to add a record to the database
-
We would like to add a record with a unique id generated by SurrealDB
-
Use a struct that does not have and id field and let the database assign one. Use a struct with the same fields and the id field to select the data.
-
Use a single struct where the id field is
Option. Let the database generate the RecordId. -
Use a single struct that has an id field and generate the id before calling create.
-
Use a
querywith a CREATE statement including an Id we generated previously. -
Use q
querywith a CREATE statement without and id field.