We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
例如调用这个方法进行查询的时候,如果判断找的数据是否存在。使用Find查找的时候,如果没有数据存在,会填入默认值,并且err也为nil。 是否应该把结果的RowsAffected 也一起返回,通过这个来判断是否找到数据
RowsAffected
func (obj *_AdminMgr) GetFromID(id uint) (result Admin, err error) { err = obj.DB.WithContext(obj.ctx).Model(Admin{}).Where("`id` = ?", id).Find(&result).Error return }
The text was updated successfully, but these errors were encountered:
通过id可以判断,
Sorry, something went wrong.
... .Model(Admin{}) ...
这里是不是可以直接使用result而不是再去新建一个结构体
func (obj *_AdminMgr) GetFromID(id uint) (result Admin, err error) { err = obj.DB.WithContext(obj.ctx).Model(result).Where("`id` = ?", id).Find(&result).Error return }
No branches or pull requests
例如调用这个方法进行查询的时候,如果判断找的数据是否存在。使用Find查找的时候,如果没有数据存在,会填入默认值,并且err也为nil。 是否应该把结果的
RowsAffected
也一起返回,通过这个来判断是否找到数据The text was updated successfully, but these errors were encountered: