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 tried to use Hooks to deal with the lock code but found that it was not satisfactory. when the 'tx.Create(&user)' occurs err or panic, AfterCreate doesn't have execute.
func (u *User) BeforeCreate(tx *grom.DB) error{
globalLock.Lock()
return nil
}
func (u *User) AfterCreate(tx *grom.DB) error{
globalLock.Unlock()
retrun nil
}
The text was updated successfully, but these errors were encountered:
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Is there a better way to handle the 'database is locked' in SQLite?
The SQLite is unsupported concurrent and only allows serial to write operation.
Description
I have to add the lock code in the per write operation to prevents the 'database is locked',For example, the following:
I tried to use Hooks to deal with the lock code but found that it was not satisfactory. when the 'tx.Create(&user)' occurs err or panic, AfterCreate doesn't have execute.
The text was updated successfully, but these errors were encountered: