Closed zgwit closed 4 years ago
Update
only updates non-zero value fields, you need to use UpdateField
. https://github.com/asdine/storm#update-an-object
Operation:
true -> false !0 -> 0 "xxx" -> ""
Must use UpdateField ?
unreasonable
Must use UpdateField ?
Yes.
unreasonable
Closing this issue as this answers the question and that the response is rude. Don't hesitate to open it if you need more info AND if you change your behavior.
I had the same problem right now. Could we update the part of the README that you linked (https://github.com/asdine/storm#update-an-object) so that it says so directly? Something like:
// Update multiple fields
// Only works for non-zero value fields
err := db.Update(&User{ID: 10, Name: "Jack", Age: 45})
// Update a single field
// Also works for zero-value fields (0, false, "", ...)
err := db.UpdateField(&User{ID: 10}, "Age", 0)
Thank you @skaldesh! Sorry I didn't see the notification on this issue
As title.
My model: `
type User struct {
}
`