In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the golang gorm update log implementation of SQL related knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe that everyone after reading this golang gorm update log implementation of SQL method article will have a harvest, let's take a look at it.
1. Update log 1.1. V1.01.1.1. Destructive change
Gorm.Open return type is * gorm.DB instead of gorm.DB
Updating only updates the changed fields
Most applications will not be affected, and only when you change the update value in the callback, such as BeforeSave,BeforeUpdate, you should use scope.SetColumn, for example:
Func (user * User) BeforeUpdate (scope * gorm.Scope) {if pw, err: = bcrypt.GenerateFromPassword (user.Password, 0); err = = nil {scope.SetColumn ("EncryptedPassword", pw) / / user.EncryptedPassword = pw / / does not work, EncryptedPassword field will not be included in the update}}
The default query scope of soft deletion only checks deleted_at IS NULL
Previously, it will check that the deleted_at is less than 0001-01-02 and exclude blank time, such as:
SELECT * FROM users WHERE deleted_at IS NULL OR deleted_at
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.