How to Create or Update a record with GORM?

前端 未结 7 1345
悲&欢浪女
悲&欢浪女 2021-01-05 04:21

Gorm has a FirstOrCreate method and a FirstOrInit but how to check afterwards if the record was actually created? I like to create a record if it d

7条回答
  •  [愿得一人]
    2021-01-05 04:46

    See Attrs here. It won't exactly tell you whether the record was actually created, but will let you update some fields only if record was actually created (which seems to be what you want to achieve in the end).

提交回复
热议问题