相关疑难解决方法(0)

如何设置隔离级别

我想将隔离级别设置为repeatable read. 我如何使用 gorm orm for postgres 实现这一点。

示例代码:

func CreateAnimals(db *gorm.DB) err {
  tx := db.Begin()
  // Note the use of tx as the database handle once you are within a transaction

  if err := tx.Create(&Animal{Name: "Giraffe"}).Error; err != nil {
     tx.Rollback()
     return err
  }

  if err := tx.Create(&Animal{Name: "Lion"}).Error; err != nil {
     tx.Rollback()
     return err
  }

  tx.Commit()
  return nil
}
Run Code Online (Sandbox Code Playgroud)

postgresql go go-gorm

4
推荐指数
1
解决办法
3358
查看次数

标签 统计

go ×1

go-gorm ×1

postgresql ×1