feat: update func
This commit is contained in:
@@ -23,6 +23,21 @@ var ordersUpdateExcludeColumns = []Column{
|
||||
table.Orders.UserID,
|
||||
}
|
||||
|
||||
func (m *Orders) Update(ctx context.Context) error {
|
||||
m.UpdatedAt = time.Now()
|
||||
|
||||
stmt := table.Orders.UPDATE(table.Orders.MutableColumns.Except(table.Orders.OrderNo, table.Orders.Price, table.Orders.Discount, table.Orders.SubOrderNo, table.Orders.PostID, table.Orders.UserID)).SET(m).WHERE(table.Orders.ID.EQ(Int(m.ID))).RETURNING(table.Orders.AllColumns)
|
||||
m.log().WithField("func", "Update").Info(stmt.DebugSql())
|
||||
|
||||
if err := stmt.QueryContext(ctx, db, m); err != nil {
|
||||
m.log().WithField("func", "Update").Errorf("error updating Orders item: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
m.log().WithField("func", "Update").Infof("Orders item updated successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
// BuildConditionWithKey builds the WHERE clause for order queries
|
||||
func (m *Orders) BuildConditionWithKey(orderNumber *string, userID *int64) BoolExpression {
|
||||
tbl := table.Orders
|
||||
|
||||
Reference in New Issue
Block a user