Replies: 2 comments
-
I have a suggestion about how this can work.
This directly solves point 2, but also solves point 1, because a single record can be updated using an appropriate query: _, err := models.UserWallets(
models.UserWalletWhere.UserID.EQ(userID), // use whatever column matches
).UpdateAll(ctx, db, models.M{
models.UserWalletColumns.Balance: balance,
}) Returning
What do you think @aarondl ? |
Beta Was this translation helpful? Give feedback.
-
@chochihim not against this. But what does the struct look like? There's a real difficulty in doing updates in both REST APIs and sql interfaces when it comes to "is this null? and I should update it? Or is this null and I should not?" It requires 3 states:
Fortunately I could merge in a change that's in the null package that would make this possible and then we -could- use a struct. |
Beta Was this translation helpful? Give feedback.
-
Can
Update
be improved?UpdateAll
to use type-safe struct instead ofmodels.M
RETURNING
clause so thatUpdate
,UpdateAll
etc methods can return the struct/slice to callerYou can refer to #970 for why I want to make this improvement
Beta Was this translation helpful? Give feedback.
All reactions