[Question] Unclear when default transaction is committed
SRNissen opened this issue · 0 comments
SRNissen commented
Document Link
https://gorm.io/docs/transactions.html
GORM perform write (create/update/delete) operations run inside a transaction to ensure data consistency, you can disable it during initialization if it is not required
Your Question
Assuming I do not disable the default transaction, when does the commit happen?
E.g.:
func main() {
db, err := gorm.Open(sqlserver.Open("connectionString"), &gorm.Config{})
if err != nil { panic("!") }
u := User{}
db.Create(&u)
?
}
Does this change get commited? If so - when?
Do I need to call .Commit()
manually? If so - when?