Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 11 for methods (0.2 sec)

  1. tests/count_test.go

    	if count != int64(len(users)) {
    		t.Errorf("Count() method should get correct value, expect: %v, got %v", count, len(users))
    	}
    
    	if err := DB.Model(&User{}).Where("name = ?", user1.Name).Or("name = ?", user3.Name).Count(&count).Find(&users).Error; err != nil {
    		t.Errorf(fmt.Sprintf("Count should work, but got err %v", err))
    	}
    
    	if count != int64(len(users)) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 6.9K bytes
    - Viewed (0)
  2. chainable_api.go

    			return
    		}
    	}
    
    	tx.Statement.Joins = append(tx.Statement.Joins, join{Name: query, Conds: args, JoinType: joinType})
    	return
    }
    
    // Group specify the group method on the find
    //
    //	// Select the sum age of users with given names
    //	db.Model(&User{}).Select("name, sum(age) as total").Group("name").Find(&results)
    func (db *DB) Group(name string) (tx *DB) {
    	tx = db.getInstance()
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  3. tests/transaction_test.go

    		return tx.Model(&User{}).Limit(1).Transaction(func(tx2 *gorm.DB) error {
    			return tx2.Scan(&User{}).Error
    		})
    	})
    
    	if err != nil {
    		t.Error(err)
    	}
    
    	// method with hooks
    	err = DB.Transaction(func(tx1 *gorm.DB) error {
    		// callMethod do
    		tx2 := tx1.Find(&User{}).Session(&gorm.Session{NewDB: true})
    		// trx in hooks
    		return tx2.Transaction(func(tx3 *gorm.DB) error {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  4. tests/connection_test.go

    			return err
    		}
    		return nil
    	})
    	if err != nil {
    		t.Errorf(fmt.Sprintf("WithSingleConnection should work, but got err %v", err))
    	}
    
    	if actualName != expectedName {
    		t.Errorf("WithSingleConnection() method should get correct value, expect: %v, got %v", expectedName, actualName)
    	}
    }
    
    func getSetSQL(driverName string) (string, string) {
    	switch driverName {
    	case mysql.Dialector{}.Name():
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 28 14:16:42 GMT 2022
    - 963 bytes
    - Viewed (0)
  5. callbacks/helper.go

    	columns := make([]string, 0, len(mapValues))
    
    	// when the length of mapValues is zero,return directly here
    	// no need to call stmt.SelectAndOmitColumns method
    	if len(mapValues) == 0 {
    		stmt.AddError(gorm.ErrEmptySlice)
    		return
    	}
    
    	var (
    		result                    = make(map[string][]interface{}, len(mapValues))
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 14 12:32:57 GMT 2022
    - 3.7K bytes
    - Viewed (0)
  6. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 19.8K bytes
    - Viewed (0)
  7. schema/schema_test.go

    	if err != nil {
    		t.Fatalf("failed to parse pointer user, got error %v", err)
    	}
    
    	if customize.Table != "customize" {
    		t.Errorf("Failed to customize table with TableName method")
    	}
    }
    
    func TestNestedModel(t *testing.T) {
    	versionUser, err := schema.Parse(&VersionUser{}, &sync.Map{}, schema.NamingStrategy{})
    	if err != nil {
    		t.Fatalf("failed to parse nested user, got error %v", err)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 12.9K bytes
    - Viewed (0)
  8. schema/schema.go

    			}
    		}
    	}
    
    	return schema, schema.err
    }
    
    // This unrolling is needed to show to the compiler the exact set of methods
    // that can be used on the modelType.
    // Prior to go1.22 any use of MethodByName would cause the linker to
    // abandon dead code elimination for the entire binary.
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Oct 10 06:50:29 GMT 2023
    - 13.7K bytes
    - Viewed (0)
  9. association.go

    package gorm
    
    import (
    	"fmt"
    	"reflect"
    	"strings"
    
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    // Association Mode contains some helper methods to handle relationship things easily.
    type Association struct {
    	DB           *DB
    	Relationship *schema.Relationship
    	Unscope      bool
    	Error        error
    }
    
    func (db *DB) Association(column string) *Association {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu May 04 11:30:45 GMT 2023
    - 21.2K bytes
    - Viewed (0)
  10. gorm.go

    }
    
    // DB GORM DB definition
    type DB struct {
    	*Config
    	Error        error
    	RowsAffected int64
    	Statement    *Statement
    	clone        int
    }
    
    // Session session config when create session with Session() method
    type Session struct {
    	DryRun                   bool
    	PrepareStmt              bool
    	NewDB                    bool
    	Initialized              bool
    	SkipHooks                bool
    	SkipDefaultTransaction   bool
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Aug 20 11:46:56 GMT 2023
    - 11.6K bytes
    - Viewed (0)
Back to top