Home
Sign Up
Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
V2EX
›
程序员
gorm 中动态处理更新字段有什么好方法没
suroppo
·
Feb 8, 2021
· 1978 views
This topic created in 1946 days ago, the information mentioned may be changed or developed.
问题主要出在更新的字段更新为默认值, 因为 gorm 中默认是不更新 struct 的默认值的. 但又不想使用 map
gorm
默认
更新
字段
3 replies
•
2021-02-09 10:30:07 +08:00
1
996635
Feb 8, 2021
加*号
2
kiripeng
Feb 8, 2021
可以写个反射遍历的结构体,然后得出 map,这样做一次封装,就不用管 map 了,之后只调用函数就行了
3
labulaka521
Feb 9, 2021
https://gorm.io/docs/update.html#Update-Selected-Fields
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
3042 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 36ms ·
UTC 14:40
·
PVG 22:40
·
LAX 07:40
·
JFK 10:40
♥ Do have faith in what you're doing.
❯