Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 24 for Account (0.19 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/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)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. migrator/migrator.go

    func (m Migrator) HasTable(value interface{}) bool {
    	var count int64
    
    	m.RunWithValue(value, func(stmt *gorm.Statement) error {
    		currentDatabase := m.DB.Migrator().CurrentDatabase()
    		return m.DB.Raw("SELECT count(*) FROM information_schema.tables WHERE table_schema = ? AND table_name = ? AND table_type = ?", currentDatabase, stmt.Table, "BASE TABLE").Row().Scan(&count)
    	})
    
    	return count > 0
    }
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  10. schema/schema_helper_test.go

    			if len(relations.Relations) != len(rs.Relations) {
    				t.Errorf("schema relations count don't match, expects %d, got %d", len(rs.Relations), len(relations.Relations))
    			}
    			if len(relations.EmbeddedRelations) != len(rs.EmbeddedRelations) {
    				t.Errorf("schema embedded relations count don't match, expects %d, got %d", len(rs.EmbeddedRelations), len(relations.EmbeddedRelations))
    			}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 7.5K bytes
    - Viewed (0)
Back to top