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
It is used for referring the model explicitly, but it is also used to update fields of existing record without the need to provide where condition separately rather in itself with struct passed to db.Model, also it is used for activating the association mode.
It can get trickier and can attract mistakes with it usage and can lead to bugs and also critical issues.
So we need to verify the usage throughout the app and make sure it is only used as per docs and not where it can be used.
For example possible mistake,
db.Model(&User{Name:"Tom"}).First(&user)
Here it is used as where condition which will not work and will return any first record present in table without matching the name Tom
The text was updated successfully, but these errors were encountered:
It is used for referring the model explicitly, but it is also used to update fields of existing record without the need to provide where condition separately rather in itself with struct passed to db.Model, also it is used for activating the association mode.
It can get trickier and can attract mistakes with it usage and can lead to bugs and also critical issues.
So we need to verify the usage throughout the app and make sure it is only used as per docs and not where it can be used.
For example possible mistake,
Here it is used as where condition which will not work and will return any first record present in table without matching the name
Tom
The text was updated successfully, but these errors were encountered: