You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to add a record with a unique id generated by SurrealDB. So not an id like joe, but one that is generated by Id::ulid or some other tool in SurrealDB.
I found a number of options, neither of them seem to be "perfect". I was wondering what would be the "best practice"
Use a struct that does not have and id field and let the database assign one. Use another 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 a struct to select.
Use q query with a CREATE statement without and id field. Use a struct to select.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to add a record with a unique id generated by SurrealDB. So not an id like
joe
, but one that is generated byId::ulid
or some other tool in SurrealDB.I found a number of options, neither of them seem to be "perfect". I was wondering what would be the "best practice"
Option
. Let the database generate theRecordId
.query
with a CREATE statement including an Id we generated previously. Use a struct to select.query
with a CREATE statement without and id field. Use a struct to select.Beta Was this translation helpful? Give feedback.
All reactions