- Sort Score
- Result 10 results
- Languages All
Results 11 - 20 of 39 for modelA (0.14 sec)
-
tests/benchmark_test.go
for x := 0; x < b.N; x++ { DB.Raw("select * from users").Scan(&u) } } func BenchmarkUpdate(b *testing.B) { user := *GetUser("find", Config{}) DB.Create(&user) for x := 0; x < b.N; x++ { DB.Model(&user).Updates(map[string]interface{}{"Age": x}) } } func BenchmarkDelete(b *testing.B) { user := *GetUser("find", Config{}) for x := 0; x < b.N; x++ { user.ID = 0 DB.Create(&user)
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Wed Jun 01 03:50:57 GMT 2022 - 1.5K bytes - Viewed (0) -
tests/named_argument_test.go
package tests_test import ( "database/sql" "errors" "testing" "gorm.io/gorm" . "gorm.io/gorm/utils/tests" ) func TestNamedArg(t *testing.T) { type NamedUser struct { gorm.Model Name1 string Name2 string Name3 string } DB.Migrator().DropTable(&NamedUser{}) DB.AutoMigrate(&NamedUser{}) namedUser := NamedUser{Name1: "jinzhu1", Name2: "jinzhu2", Name3: "jinzhu3"} DB.Create(&namedUser)
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Tue Dec 21 11:50:00 GMT 2021 - 2.7K bytes - Viewed (0) -
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) -
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) -
tests/hooks_test.go
t.Fatalf("Failed to query product, got error: %v", err) } DB.Model(&result3).Update("Price", 800) var result4 Product2 DB.First(&result4, "name = ?", "Nice2") if result4.Price != 600 { t.Errorf("Admin product's price should not be changed, expects: %v, got %v", 600, result4.Price) } } type Product3 struct { gorm.Model Name string Code string Price int64 Owner string }
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Sat Feb 18 01:20:29 GMT 2023 - 15.9K bytes - Viewed (0) -
chainable_api.go
"gorm.io/gorm/clause" "gorm.io/gorm/utils" ) // Model specify the model you would like to run db operations // // // update all users's name to `hello` // db.Model(&User{}).Update("name", "hello") // // if user's primary key is non-blank, will use it as condition, then will only update that user's name to `hello` // db.Model(&user).Update("name", "hello") func (db *DB) Model(value interface{}) (tx *DB) { tx = db.getInstance()
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Wed Apr 17 03:38:55 GMT 2024 - 14.3K bytes - Viewed (1) -
tests/distinct_test.go
AssertObjEqual(t, results[idx], expect, "Name", "Age") } var count int64 if err := DB.Model(&User{}).Where("name like ?", "distinct%").Count(&count).Error; err != nil || count != 5 { t.Errorf("failed to query users count, got error: %v, count: %v", err, count) } if err := DB.Model(&User{}).Distinct("name").Where("name like ?", "distinct%").Count(&count).Error; err != nil || count != 3 {
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 2.5K bytes - Viewed (0) -
soft_delete.go
stmt.AddClause(clause.Where{Exprs: []clause.Expression{clause.IN{Column: column, Values: values}}}) } if stmt.ReflectValue.CanAddr() && stmt.Dest != stmt.Model && stmt.Model != nil { _, queryValues = schema.GetIdentityFieldValuesMap(stmt.Context, reflect.ValueOf(stmt.Model), stmt.Schema.PrimaryFields) column, values = schema.ToQueryValues(stmt.Table, stmt.Schema.PrimaryFieldDBNames, queryValues) if len(values) > 0 {
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Wed Feb 01 06:40:55 GMT 2023 - 4.5K bytes - Viewed (0) -
migrator/migrator.go
// // // CREATE VIEW `user_view` AS SELECT * FROM `users` WHERE age > 20 // q := DB.Model(&User{}).Where("age > ?", 20) // DB.Debug().Migrator().CreateView("user_view", gorm.ViewOption{Query: q}) // // // CREATE OR REPLACE VIEW `users_view` AS SELECT * FROM `users` WITH CHECK OPTION // q := DB.Model(&User{})
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Fri Apr 26 07:15:49 GMT 2024 - 29K bytes - Viewed (0) -
tests/postgres_test.go
t.Errorf("No error should happen, but got %v", err) } } func TestPostgres(t *testing.T) { if DB.Dialector.Name() != "postgres" { t.Skip() } type Harumph struct { gorm.Model Name string `gorm:"check:name_checker,name <> ''"` Test uuid.UUID `gorm:"type:uuid;not null;default:gen_random_uuid()"` CreatedAt time.Time `gorm:"type:TIMESTAMP WITHOUT TIME ZONE"`
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Sat Oct 08 09:16:32 GMT 2022 - 6.4K bytes - Viewed (3)