Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 109 for model (0.16 sec)

  1. model.go

    package gorm
    
    import "time"
    
    // Model a basic GoLang struct which includes the following fields: ID, CreatedAt, UpdatedAt, DeletedAt
    // It may be embedded into your model or you may build your own model without it
    //
    //	type User struct {
    //	  gorm.Model
    //	}
    type Model struct {
    	ID        uint `gorm:"primarykey"`
    	CreatedAt time.Time
    	UpdatedAt time.Time
    	DeletedAt DeletedAt `gorm:"index"`
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Feb 18 01:06:43 GMT 2023
    - 396 bytes
    - Viewed (0)
  2. schema/model_test.go

    package schema_test
    
    import (
    	"database/sql"
    	"time"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/utils/tests"
    )
    
    type User struct {
    	*gorm.Model
    	Name      *string
    	Age       *uint
    	Birthday  *time.Time
    	Account   *tests.Account
    	Pets      []*tests.Pet
    	Toys      []*tests.Toy `gorm:"polymorphic:Owner"`
    	CompanyID *int
    	Company   *tests.Company
    	ManagerID *uint
    	Manager   *User
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.1K bytes
    - Viewed (0)
  3. tests/associations_many2many_test.go

    	// Find
    	var user2 User
    	DB.Find(&user2, "id = ?", user.ID)
    	DB.Model(&user2).Association("Languages").Find(&user2.Languages)
    
    	CheckUser(t, user2, user)
    
    	// Count
    	AssertAssociationCount(t, user, "Languages", 2, "")
    
    	// Append
    	language := Language{Code: "language-many2many-append", Name: "language-many2many-append"}
    	DB.Create(&language)
    
    	if err := DB.Model(&user2).Association("Languages").Append(&language); err != nil {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 13.2K bytes
    - Viewed (0)
  4. tests/associations_test.go

    	var emptyUser User
    	var err error
    	// belongs to
    	err = DB.Model(&emptyUser).Association("Company").Delete(&user1.Company)
    	AssertEqual(t, err, gorm.ErrPrimaryKeyRequired)
    	// has many
    	err = DB.Model(&emptyUser).Association("Pets").Delete(&user1.Pets)
    	AssertEqual(t, err, gorm.ErrPrimaryKeyRequired)
    	// has one
    	err = DB.Model(&emptyUser).Association("Account").Delete(&user1.Account)
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Feb 08 08:29:09 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  5. association.go

    					association.Error = associationDB.Model(nil).Where(clause.IN{Column: column, Values: values}).Delete(reflect.New(rel.FieldSchema.ModelType).Interface()).Error
    				}
    			}
    		case schema.HasOne, schema.HasMany:
    			model := reflect.New(rel.FieldSchema.ModelType).Interface()
    			tx := association.DB.Model(model)
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu May 04 11:30:45 GMT 2023
    - 21.2K bytes
    - Viewed (0)
  6. 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)
  7. tests/named_polymorphic_test.go

    	}
    
    	if DB.Model(&hamster2).Association("OtherToy").Count() != 1 {
    		t.Errorf("Hamster's toys count should be 1 after Append")
    	}
    
    	// Replace
    	DB.Model(&hamster).Association("PreferredToy").Replace(&Toy{
    		Name: "bike 3",
    	})
    
    	DB.Model(&hamster).Association("OtherToy").Replace(&Toy{
    		Name: "treadmill 3",
    	})
    
    	hamsterToy = Toy{}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Jul 08 09:59:40 GMT 2020
    - 4.2K bytes
    - Viewed (0)
  8. istioctl/pkg/writer/envoy/configdump/cluster.go

    	"istio.io/istio/istioctl/pkg/util/proto"
    	"istio.io/istio/pilot/pkg/model"
    	v3 "istio.io/istio/pilot/pkg/xds/v3"
    	"istio.io/istio/pkg/config/host"
    )
    
    // ClusterFilter is used to pass filter information into cluster based config writer print functions
    type ClusterFilter struct {
    	FQDN      host.Name
    	Port      int
    	Subset    string
    	Direction model.TrafficDirection
    }
    
    Go
    - Registered: Wed May 01 22:53:12 GMT 2024
    - Last Modified: Thu May 11 05:38:17 GMT 2023
    - 5.9K bytes
    - Viewed (0)
  9. tests/multi_primary_keys_test.go

    	DB.Model(&blog).Association("Tags").Delete(tag5)
    	var tags3 []Tag
    	DB.Model(&blog).Association("Tags").Find(&tags3)
    	if !compareTags(tags3, []string{"tag6"}) {
    		t.Fatalf("Should find 1 tags after Delete")
    	}
    
    	if DB.Model(&blog).Association("Tags").Count() != 1 {
    		t.Fatalf("Blog should has three tags after Delete")
    	}
    
    	DB.Model(&blog).Association("Tags").Delete(tag3)
    	var tags4 []Tag
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 12.8K bytes
    - Viewed (0)
  10. tests/query_test.go

    				})
    			}
    		}
    	})
    
    	var models []User
    	if err := DB.Where("name in (?)", []string{"find"}).Find(&models).Error; err != nil || len(models) != 3 {
    		t.Errorf("errors happened when query find with in clause: %v, length: %v", err, len(models))
    	} else {
    		for idx, user := range users {
    			t.Run("FindWithInClause#"+strconv.Itoa(idx+1), func(t *testing.T) {
    				CheckUser(t, models[idx], user)
    			})
    		}
    	}
    
    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)
Back to top