When a type conforms to PrimaryKeyedTable, the @Table macro generates a nested Draft type. This type contains all the same fields as the original type, but the primary key field is optional. This is useful for inserting rows where the database is responsible for generating the ID (e.g., auto-incrementing integers or UUIDs).
You can use the insert(_:onConflict:) method to insert a row using a Draft object. To retrieve the generated ID or the full record after insertion, chain the returning(_:) method.
// Inserting a draft and returning the new ID
Reminder
.insert { Reminder.Draft(title: "Get groceries") }
.returning(\.id)
// Inserting a draft and returning the full record
Reminder
.insert { Reminder.Draft(title: "Get groceries") }
.returning(\.self)