Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 33 for Model (0.51 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 May 05 09:35:13 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 May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.1K bytes
    - Viewed (0)
  3. tests/associations_has_one_test.go

    	CheckUser(t, user, user)
    
    	// Find
    	var user2 User
    	DB.Find(&user2, "id = ?", user.ID)
    	DB.Model(&user2).Association("Account").Find(&user2.Account)
    	CheckUser(t, user2, user)
    
    	// Count
    	AssertAssociationCount(t, user, "Account", 1, "")
    
    	// Append
    	account := Account{Number: "account-has-one-append"}
    
    	if err := DB.Model(&user2).Association("Account").Append(&account); err != nil {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 6.8K bytes
    - Viewed (0)
  4. tests/scan_test.go

    	if res.ID != user2.ID || res.Name != user2.Name || res.Age != int(user2.Age) {
    		t.Fatalf("Scan into struct should work, got %#v, should %#v", res, user2)
    	}
    
    	DB.Model(&User{Model: gorm.Model{ID: user3.ID}}).Select("id, name, age").Scan(&res)
    	if res.ID != user3.ID || res.Name != user3.Name || res.Age != int(user3.Age) {
    		t.Fatalf("Scan into struct should work, got %#v, should %#v", res, user3)
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat May 28 14:18:07 GMT 2022
    - 8.2K bytes
    - Viewed (0)
  5. tests/soft_delete_test.go

    	user := *GetUser("SoftDelete", Config{})
    	DB.Save(&user)
    
    	var count int64
    	var age uint
    
    	if DB.Model(&User{}).Where("name = ?", user.Name).Count(&count).Error != nil || count != 1 {
    		t.Errorf("Count soft deleted record, expects: %v, got: %v", 1, count)
    	}
    
    	if DB.Model(&User{}).Select("age").Where("name = ?", user.Name).Scan(&age).Error != nil || age != user.Age {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Feb 01 06:40:55 GMT 2023
    - 5.7K bytes
    - Viewed (0)
  6. tests/count_test.go

    	})
    
    	var count1 int64
    	if err := DB.Model(&Company{}).Where("name = ?", "company_count_group_a").Group("name").Count(&count1).Error; err != nil {
    		t.Errorf(fmt.Sprintf("Count should work, but got err %v", err))
    	}
    	if count1 != 1 {
    		t.Errorf("Count with group should be 1, but got count: %v", count1)
    	}
    
    	var count2 int64
    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)
  7. callbacks.go

    		optimizer.ModifyStatement(stmt)
    	}
    
    	// assign model values
    	if stmt.Model == nil {
    		stmt.Model = stmt.Dest
    	} else if stmt.Dest == nil {
    		stmt.Dest = stmt.Model
    	}
    
    	// parse model values
    	if stmt.Model != nil {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 26 03:33:36 GMT 2024
    - 8.6K bytes
    - Viewed (1)
  8. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  9. .github/FUNDING.yml

    # These are supported funding model platforms
    
    github: [jinzhu]
    patreon: jinzhu
    Others
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Jun 07 04:47:26 GMT 2020
    - 102 bytes
    - Viewed (0)
  10. tests/update_has_one_test.go

    		CheckPet(t, pet4, pet)
    	})
    
    	t.Run("Restriction", func(t *testing.T) {
    		type CustomizeAccount struct {
    			gorm.Model
    			UserID  sql.NullInt64
    			Number  string `gorm:"<-:create"`
    			Number2 string
    		}
    
    		type CustomizeUser struct {
    			gorm.Model
    			Name    string
    			Account CustomizeAccount `gorm:"foreignkey:UserID"`
    		}
    
    		DB.Migrator().DropTable(&CustomizeUser{})
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jul 14 06:55:54 GMT 2022
    - 3.6K bytes
    - Viewed (0)
Back to top