Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 query with a CREATE statement including an Id we generated previously.

  • Use q query with a CREATE statement without and id field.