Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 36 for Account (0.22 sec)

  1. utils/tests/models.go

    type User struct {
    	gorm.Model
    	Name      string
    	Age       uint
    	Birthday  *time.Time
    	Account   Account
    	Pets      []*Pet
    	NamedPet  *Pet
    	Toys      []Toy   `gorm:"polymorphic:Owner"`
    	Tools     []Tools `gorm:"polymorphicType:Type;polymorphicId:CustomID"`
    	CompanyID *int
    	Company   Company
    	ManagerID *uint
    	Manager   *User
    	Team      []User     `gorm:"foreignkey:ManagerID"`
    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. chainable_api.go

    	}
    	return
    }
    
    // Joins specify Joins conditions
    //
    //	db.Joins("Account").Find(&user)
    //	db.Joins("JOIN emails ON emails.user_id = users.id AND emails.email = ?", "******@****.***").Find(&user)
    //	db.Joins("Account", DB.Select("id").Where("user_id = users.id AND name = ?", "someName").Model(&Account{}))
    func (db *DB) Joins(query string, args ...interface{}) (tx *DB) {
    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)
  3. tests/associations_has_one_test.go

    	account := Account{Number: "account-has-one-append"}
    
    	if err := DB.Model(&user2).Association("Account").Append(&account); err != nil {
    		t.Fatalf("Error happened when append account, got %v", err)
    	}
    
    	if account.ID == 0 {
    		t.Fatalf("Account's ID should be created")
    	}
    
    	user.Account = account
    	CheckUser(t, user2, user)
    
    	AssertAssociationCount(t, user, "Account", 1, "AfterAppend")
    
    	// Replace
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 6.8K bytes
    - Viewed (0)
  4. tests/upsert_test.go

    	if err := DB.Where("name = ?", "first_or_create_pet1").First(&Pet{}).Error; err != nil {
    		t.Errorf("has many association should be saved")
    	}
    
    	if err := DB.Where("number = ?", "1231231231").First(&Account{}).Error; err != nil {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Sep 05 07:39:19 GMT 2022
    - 11.4K bytes
    - Viewed (0)
  5. tests/update_test.go

    		t.Errorf("should update two records, but got %v", rowsAffected)
    	}
    
    	var results []User
    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)
  6. tests/helper_test.go

    		"ManagerID", "Active")
    
    	t.Run("Account", func(t *testing.T) {
    		AssertObjEqual(t, user.Account, expect.Account, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Number")
    
    		if user.Account.Number != "" {
    			if !user.Account.UserID.Valid {
    				t.Errorf("Account's foreign key should be saved")
    			} else {
    				var account Account
    				db(unscoped).First(&account, "user_id = ?", user.ID)
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  7. tests/transaction_test.go

    	}); err == nil {
    		t.Errorf("should returns error when commit with closed conn, got error %v", err)
    	}
    }
    
    func TestTransactionWithHooks(t *testing.T) {
    	user := GetUser("tTestTransactionWithHooks", Config{Account: true})
    	DB.Create(&user)
    
    	var err error
    	err = DB.Transaction(func(tx *gorm.DB) error {
    		return tx.Model(&User{}).Limit(1).Transaction(func(tx2 *gorm.DB) error {
    			return tx2.Scan(&User{}).Error
    		})
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  8. tests/preload_test.go

    	}
    
    	var users2 []User
    	DB.Preload("Account", clause.Eq{Column: "number", Value: users[0].Account.Number}).Find(&users2, "id IN ?", userIDs)
    	sort.Slice(users2, func(i, j int) bool {
    		return users2[i].ID < users2[j].ID
    	})
    
    	for idx, user := range users2[1:2] {
    		if user.Account.Number != "" {
    			t.Errorf("No account should found for user %v but got %v", idx+2, user.Account.Number)
    		}
    	}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 14.9K bytes
    - Viewed (0)
  9. tests/delete_test.go

    	}
    
    	for key, value := range map[string]int64{"Account": 1, "Pets": 2, "Toys": 4, "Company": 1, "Manager": 1, "Team": 1, "Languages": 0, "Friends": 0} {
    		if count := DB.Unscoped().Model(&user).Association(key).Count(); count != value {
    			t.Errorf("user's %v expects: %v, got %v", key, value, count)
    		}
    	}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Oct 10 07:03:34 GMT 2023
    - 9.4K bytes
    - Viewed (0)
  10. tests/migrate_test.go

    	if err := DB.Migrator().CreateView("users_pets", gorm.ViewOption{Query: query}); err != nil {
    		t.Fatalf("Failed to crate view, got %v", err)
    	}
    
    	var count int64
    	if err := DB.Table("users_pets").Count(&count).Error; err != nil {
    		t.Fatalf("should found created view")
    	}
    
    	if err := DB.Migrator().DropView("users_pets"); err != nil {
    		t.Fatalf("Failed to drop view, got %v", err)
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
Back to top