Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 41 for Model (0.17 sec)

  1. utils/tests/models.go

    	Active    bool
    }
    
    type Account struct {
    	gorm.Model
    	UserID sql.NullInt64
    	Number string
    }
    
    type Pet struct {
    	gorm.Model
    	UserID *uint
    	Name   string
    	Toy    Toy `gorm:"polymorphic:Owner;"`
    }
    
    type Toy struct {
    	gorm.Model
    	Name      string
    	OwnerID   string
    	OwnerType string
    }
    
    type Tools struct {
    	gorm.Model
    	Name     string
    	CustomID string
    	Type     string
    }
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  2. tests/update_test.go

    	}
    
    	user3.Name = "save3_"
    	if err := DB.Model(User{Model: user3.Model}).Save(&user3).Error; err != nil {
    		t.Fatalf("failed to save user, got %v", err)
    	}
    
    	var result2 User
    	if err := DB.First(&result2, "name = ?", "save3_").Error; err != nil || result2.ID != user3.ID {
    		t.Fatalf("failed to find updated user, got %v", err)
    	}
    
    	if err := DB.Model(User{Model: user3.Model}).Save(&struct {
    		gorm.Model
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
  3. tests/associations_belongs_to_test.go

    	// Clear
    	DB.Model(&users).Association("Company").Clear()
    	AssertAssociationCount(t, users, "Company", 0, "After Clear")
    
    	DB.Model(&users).Association("Manager").Clear()
    	AssertAssociationCount(t, users, "Manager", 0, "After Clear")
    
    	// shared company
    	company := Company{Name: "shared"}
    	if err := DB.Model(&users[0]).Association("Company").Append(&company); err != nil {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
  4. tests/sql_builder_test.go

    	dryRunDB := DB.Session(&gorm.Session{DryRun: true})
    
    	stmt := dryRunDB.Model(&user).Where("id = ?", 1).Updates(map[string]interface{}{"age": ageInt(8)}).Statement
    	sql := DB.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
    	if !regexp.MustCompile(`.*age.*=8,`).MatchString(sql) {
    		t.Errorf("Failed to generate sql, got %v", sql)
    	}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 16.7K bytes
    - Viewed (0)
  5. tests/query_test.go

    	var simpleUser2 SimpleUser
    	if err := DB.Model(&User{}).Select("id").First(&simpleUser2, user.ID).Error; err != nil {
    		t.Fatalf("Failed to query smaller user, got error %v", err)
    	}
    
    	AssertObjEqual(t, user, simpleUser2, "ID")
    
    	var simpleUsers []SimpleUser
    	if err := DB.Model(&User{}).Select("id").Find(&simpleUsers, user.ID).Error; err != nil || len(simpleUsers) != 1 {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 49.8K bytes
    - Viewed (0)
  6. chainable_api.go

    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/utils"
    )
    
    // Model specify the model you would like to run db operations
    //
    //	// update all users's name to `hello`
    //	db.Model(&User{}).Update("name", "hello")
    //	// if user's primary key is non-blank, will use it as condition, then will only update that user's name to `hello`
    //	db.Model(&user).Update("name", "hello")
    func (db *DB) Model(value interface{}) (tx *DB) {
    	tx = db.getInstance()
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  7. schema/schema_test.go

    		{Name: "ID", DBName: "id", BindNames: []string{"Model", "ID"}, DataType: schema.Uint, PrimaryKey: true, Tag: `gorm:"primarykey"`, TagSettings: map[string]string{"PRIMARYKEY": "PRIMARYKEY"}, Size: 64, HasDefaultValue: true, AutoIncrement: true},
    		{Name: "CreatedAt", DBName: "created_at", BindNames: []string{"Model", "CreatedAt"}, DataType: schema.Time},
    		{Name: "UpdatedAt", DBName: "updated_at", BindNames: []string{"Model", "UpdatedAt"}, DataType: schema.Time},
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 12.9K bytes
    - Viewed (0)
  8. callbacks/update.go

    	"gorm.io/gorm/utils"
    )
    
    func SetupUpdateReflectValue(db *gorm.DB) {
    	if db.Error == nil && db.Statement.Schema != nil {
    		if !db.Statement.ReflectValue.CanAddr() || db.Statement.Model != db.Statement.Dest {
    			db.Statement.ReflectValue = reflect.ValueOf(db.Statement.Model)
    			for db.Statement.ReflectValue.Kind() == reflect.Ptr {
    				db.Statement.ReflectValue = db.Statement.ReflectValue.Elem()
    			}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 05:44:55 GMT 2024
    - 9.4K bytes
    - Viewed (1)
  9. istioctl/pkg/writer/pilot/status_test.go

    	discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
    	status "github.com/envoyproxy/go-control-plane/envoy/service/status/v3"
    	"google.golang.org/protobuf/types/known/anypb"
    
    	"istio.io/istio/pilot/pkg/model"
    	"istio.io/istio/pilot/pkg/util/protoconv"
    	"istio.io/istio/pilot/pkg/xds"
    	v3 "istio.io/istio/pilot/pkg/xds/v3"
    	"istio.io/istio/pkg/cluster"
    	"istio.io/istio/pkg/test/util/assert"
    Go
    - Registered: Wed Apr 24 22:53:08 GMT 2024
    - Last Modified: Fri Mar 08 08:38:19 GMT 2024
    - 6.5K bytes
    - Viewed (0)
  10. cmd/iam-etcd-store.go

    	//  a large number of policies
    	r, err := ies.client.Get(ctx, iamConfigPoliciesPrefix, etcd.WithPrefix())
    	if err != nil {
    		return err
    	}
    
    	// Parse all values to construct the policies data model.
    	for _, kvs := range r.Kvs {
    		if err = ies.getPolicyDocKV(ctx, kvs, m); err != nil && !errors.Is(err, errNoSuchPolicy) {
    			return err
    		}
    	}
    	return nil
    }
    
    Go
    - Registered: Sun Apr 28 19:28:10 GMT 2024
    - Last Modified: Thu Apr 04 12:04:40 GMT 2024
    - 13.6K bytes
    - Viewed (0)
Back to top