Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 11 for tots (0.12 sec)

  1. tests/associations_has_many_test.go

    		*GetUser("slice-hasmany-2", Config{Toys: 0, Tools: 2}),
    		*GetUser("slice-hasmany-3", Config{Toys: 4}),
    	}
    
    	DB.Create(&users)
    
    	// Count
    	AssertAssociationCount(t, users, "Toys", 6, "")
    	AssertAssociationCount(t, users, "Tools", 2, "")
    
    	// Find
    	var toys []Toy
    	if DB.Model(&users).Association("Toys").Find(&toys); len(toys) != 6 {
    		t.Errorf("toys count should be %v, but got %v", 6, len(toys))
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 15.6K bytes
    - Viewed (0)
  2. tests/create_test.go

    		*GetUser("bulk_5", Config{Account: false, Pets: 0, Toys: 3, Company: true, Manager: false, Team: 1, Languages: 3, Friends: 1}),
    		*GetUser("bulk_6", Config{Account: true, Pets: 4, Toys: 3, Company: false, Manager: true, Team: 1, Languages: 3, Friends: 0}),
    		*GetUser("bulk_7", Config{Account: true, Pets: 1, Toys: 3, Company: true, Manager: true, Team: 4, Languages: 3, Friends: 1}),
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 26.4K bytes
    - Viewed (0)
  3. schema/relationship_test.go

    		ID  int
    		Cat struct {
    			Name string
    			Toy  Toy   `gorm:"polymorphic:Owner;"`
    			Toys []Toy `gorm:"polymorphic:Owner;"`
    		} `gorm:"embedded;embeddedPrefix:cat_"`
    		Dog struct {
    			ID     int
    			Name   string
    			UserID int
    			Toy    Toy   `gorm:"polymorphic:Owner;"`
    			Toys   []Toy `gorm:"polymorphic:Owner;"`
    		}
    		Toys []Toy `gorm:"polymorphic:Owner;"`
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  4. tests/count_test.go

    		Preload("Toys", func(db *gorm.DB) *gorm.DB {
    			return db.Table("toys").Select("name")
    		}).Count(&count12).Error; err == nil {
    		t.Errorf("error should raise when using preload without schema")
    	}
    
    	var count13 int64
    	if err := DB.Model(User{}).
    		Where("name in ?", []string{user1.Name, user2.Name, user3.Name}).
    		Preload("Toys", func(db *gorm.DB) *gorm.DB {
    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)
  5. utils/tests/models.go

    package tests
    
    import (
    	"database/sql"
    	"time"
    
    	"gorm.io/gorm"
    )
    
    // User has one `Account` (has one), many `Pets` (has many) and `Toys` (has many - polymorphic)
    // He works in a Company (belongs to), he has a Manager (belongs to - single-table), and also managed a Team (has many - single-table)
    // He speaks many languages (many to many) and has many friends (many to many - single-table)
    // His pet also has one Toy (has one - polymorphic)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  6. tests/preload_suits_test.go

    			t.Error(err)
    		}
    	}
    
    	var gots []*Level3
    	if err := DB.Preload("Level2.Level1s", func(db *gorm.DB) *gorm.DB {
    		return db.Order("level1.id ASC")
    	}).Find(&gots).Error; err != nil {
    		t.Error(err)
    	}
    
    	if !reflect.DeepEqual(gots, wants) {
    		t.Errorf("got %s; want %s", toJSONString(gots), toJSONString(wants))
    	}
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Mar 18 05:38:46 GMT 2022
    - 30.3K bytes
    - Viewed (0)
  7. tests/delete_test.go

    		*GetUser("delete_slice_with_associations1", Config{Account: true, Pets: 4, Toys: 1, Company: true, Manager: true, Team: 1, Languages: 1, Friends: 4}),
    		*GetUser("delete_slice_with_associations2", Config{Account: true, Pets: 3, Toys: 2, Company: true, Manager: true, Team: 2, Languages: 2, Friends: 3}),
    		*GetUser("delete_slice_with_associations3", Config{Account: true, Pets: 2, Toys: 3, Company: true, Manager: true, Team: 3, Languages: 3, Friends: 2}),
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Oct 10 07:03:34 GMT 2023
    - 9.4K bytes
    - Viewed (0)
  8. tests/named_polymorphic_test.go

    	}
    
    	if DB.Model(&hamster2).Association("PreferredToy").Count() != 1 {
    		t.Errorf("Hamster's toys count should be 1 after Append")
    	}
    
    	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",
    	})
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Jul 08 09:59:40 GMT 2020
    - 4.2K bytes
    - Viewed (0)
  9. schema/model_test.go

    	"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
    	Team      []*User           `gorm:"foreignkey:ManagerID"`
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.1K bytes
    - Viewed (0)
  10. tests/preload_test.go

    	"gorm.io/gorm/clause"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestPreloadWithAssociations(t *testing.T) {
    	user := *GetUser("preload_with_associations", Config{
    		Account:   true,
    		Pets:      2,
    		Toys:      3,
    		Company:   true,
    		Manager:   true,
    		Team:      4,
    		Languages: 3,
    		Friends:   1,
    	})
    
    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 14.9K bytes
    - Viewed (0)
Back to top