- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 18 for many2many (0.23 sec)
-
tests/update_many2many_test.go
package tests_test import ( "testing" "gorm.io/gorm" . "gorm.io/gorm/utils/tests" ) func TestUpdateMany2ManyAssociations(t *testing.T) { user := *GetUser("update-many2many", Config{}) if err := DB.Create(&user).Error; err != nil { t.Fatalf("errors happened when create: %v", err) } user.Languages = []Language{{Code: "zh-CN", Name: "Chinese"}, {Code: "en", Name: "English"}} for _, lang := range user.Languages {
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 1.3K bytes - Viewed (0) -
tests/associations_many2many_test.go
} // Append languages1 := []Language{ {Code: "language-many2many-append-1", Name: "language-many2many-append-1"}, } languages2 := []Language{} languages3 := []Language{ {Code: "language-many2many-append-3-1", Name: "language-many2many-append-3-1"}, {Code: "language-many2many-append-3-2", Name: "language-many2many-append-3-2"}, } DB.Create(&languages1) DB.Create(&languages3)
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Sat Jun 10 13:05:19 GMT 2023 - 13.2K bytes - Viewed (0) -
schema/relationship_test.go
Subject string Body string Tags []Tag `gorm:"many2many:blog_tags;"` SharedTags []Tag `gorm:"many2many:shared_blog_tags;ForeignKey:id;References:id"` LocaleTags []Tag `gorm:"many2many:locale_blog_tags;ForeignKey:id,locale;References:id"` } checkStructRelation(t, &Blog{}, Relation{ Name: "Tags", Type: schema.Many2Many, Schema: "Blog", FieldSchema: "Tag",
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) -
tests/preload_suits_test.go
Level1 struct { ID uint Value string } Level2 struct { ID uint Value string Level1s []*Level1 `gorm:"many2many:level1_level2;"` } Level3 struct { ID uint Value string Level2s []Level2 `gorm:"many2many:level2_level3;"` } ) DB.Migrator().DropTable(&Level3{}, &Level2{}, &Level1{}, "level1_level2", "level2_level3")
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) -
utils/tests/models.go
CompanyID *int Company Company ManagerID *uint Manager *User Team []User `gorm:"foreignkey:ManagerID"` Languages []Language `gorm:"many2many:UserSpeak;"` Friends []*User `gorm:"many2many:user_friends;"` Active bool } type Account struct { gorm.Model UserID sql.NullInt64 Number string } type Pet struct { gorm.Model UserID *uint
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) -
tests/embedded_struct_test.go
t.Errorf("Failed to create got error %v", err) } } func TestEmbeddedRelations(t *testing.T) { type EmbUser struct { gorm.Model Name string Age uint Languages []Language `gorm:"many2many:EmbUserSpeak;"` } type AdvancedUser struct { EmbUser `gorm:"embedded"` Advanced bool } DB.Migrator().DropTable(&AdvancedUser{})
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Thu Oct 26 03:58:13 GMT 2023 - 7.3K bytes - Viewed (0) -
tests/postgres_test.go
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4();"` Title string Categories []*Category `gorm:"Many2Many:post_categories"` } type Category struct { ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4();"` Title string Posts []*Post `gorm:"Many2Many:post_categories"` } func TestMany2ManyWithDefaultValueUUID(t *testing.T) { if DB.Dialector.Name() != "postgres" {
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) -
callbacks/associations.go
} saveAssociations(db, rel, elems, selectColumns, restricted, assignmentColumns) } } // Save Many2Many associations for _, rel := range db.Statement.Schema.Relationships.Many2Many { if v, ok := selectColumns[rel.Name]; (ok && !v) || (!ok && restricted) { continue } fieldType := rel.Field.IndirectFieldType.Elem()
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Tue Apr 11 03:06:13 GMT 2023 - 14.3K bytes - Viewed (0) -
callbacks/delete.go
withoutConditions = true break } } if !withoutConditions && db.AddError(tx.Clauses(clause.Where{Exprs: queryConds}).Delete(modelValue).Error) != nil { return } case schema.Many2Many: var ( queryConds = make([]clause.Expression, 0, len(rel.References)) foreignFields = make([]*schema.Field, 0, len(rel.References)) relForeignKeys = make([]string, 0, len(rel.References))
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Fri Feb 25 02:48:23 GMT 2022 - 5.6K bytes - Viewed (0) -
migrator/migrator.go
return &uni, stmt.Table } getTable := func(rel *schema.Relationship) string { switch rel.Type { case schema.HasOne, schema.HasMany: return rel.FieldSchema.Table case schema.Many2Many: return rel.JoinTable.Table } return stmt.Table } for _, rel := range stmt.Schema.Relationships.Relations { if constraint := rel.ParseConstraint(); constraint != nil && constraint.Name == name {
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Fri Apr 26 07:15:49 GMT 2024 - 29K bytes - Viewed (0)