Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for setColumn (0.19 sec)

  1. statement.go

    		newStmt.Settings.Store(k, v)
    		return true
    	})
    
    	return newStmt
    }
    
    // SetColumn set column's value
    //
    //	stmt.SetColumn("Name", "jinzhu") // Hooks Method
    //	stmt.SetColumn("Name", "jinzhu", true) // Callbacks Method
    func (stmt *Statement) SetColumn(name string, value interface{}, fromCallbacks ...bool) {
    	if v, ok := stmt.Dest.(map[string]interface{}); ok {
    		v[name] = value
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 19.8K bytes
    - Viewed (0)
  2. tests/hooks_test.go

    }
    
    func (s Product3) BeforeCreate(tx *gorm.DB) (err error) {
    	tx.Statement.SetColumn("Price", s.Price+100)
    	return nil
    }
    
    func (s Product3) BeforeUpdate(tx *gorm.DB) (err error) {
    	if tx.Statement.Changed() {
    		tx.Statement.SetColumn("Price", s.Price+10)
    	}
    
    	if tx.Statement.Changed("Code") {
    		s.Price += 20
    		tx.Statement.SetColumn("Price", s.Price+30)
    	}
    	return nil
    }
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 15.9K bytes
    - Viewed (0)
  3. soft_delete.go

    	if stmt.SQL.Len() == 0 && !stmt.Statement.Unscoped {
    		curTime := stmt.DB.NowFunc()
    		stmt.AddClause(clause.Set{{Column: clause.Column{Name: sd.Field.DBName}, Value: curTime}})
    		stmt.SetColumn(sd.Field.DBName, curTime, true)
    
    		if stmt.Schema != nil {
    			_, queryValues := schema.GetIdentityFieldValuesMap(stmt.Context, stmt.ReflectValue, stmt.Schema.PrimaryFields)
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Wed Feb 01 06:40:55 GMT 2023
    - 4.5K bytes
    - Viewed (0)
Back to top