- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 50 for belongsTo (0.18 sec)
-
schema/relationship.go
HasMany RelationshipType = "has_many" // HasManyRel has many relationship BelongsTo RelationshipType = "belongs_to" // BelongsToRel belongs to relationship Many2Many RelationshipType = "many_to_many" // Many2ManyRel many to many relationship has RelationshipType = "has" ) type Relationships struct { HasOne []*Relationship BelongsTo []*Relationship HasMany []*Relationship Many2Many []*Relationship
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Mon Apr 15 03:20:20 GMT 2024 - 22.4K bytes - Viewed (0) -
schema/relationship_test.go
"Country": { Name: "Country", Type: schema.BelongsTo, Schema: "Org", FieldSchema: "Country", References: []Reference{ {PrimaryKey: "ID", PrimarySchema: "Country", ForeignKey: "CountryID", ForeignSchema: "Org"}, }, }, }, }, "VisitingAddress": { Relations: map[string]Relation{ "Country": { Name: "Country", Type: schema.BelongsTo, Schema: "Org", FieldSchema: "Country",
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Mon Apr 15 03:20:20 GMT 2024 - 25.5K bytes - Viewed (0) -
association.go
reflectValue := association.DB.Statement.ReflectValue rel := association.Relationship var oldBelongsToExpr clause.Expression // we have to record the old BelongsTo value if association.Unscope && rel.Type == schema.BelongsTo { var foreignFields []*schema.Field for _, ref := range rel.References { if !ref.OwnPrimaryKey { foreignFields = append(foreignFields, ref.ForeignKey) } }
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Thu May 04 11:30:45 GMT 2023 - 21.2K bytes - Viewed (0) -
schema/schema_test.go
}, { Name: "Company", Type: schema.BelongsTo, Schema: "User", FieldSchema: "Company", References: []Reference{{"ID", "Company", "CompanyID", "User", "", false}}, }, { Name: "Manager", Type: schema.BelongsTo, Schema: "User", FieldSchema: "User", References: []Reference{{"ID", "User", "ManagerID", "User", "", false}}, }, {
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Fri Dec 15 08:31:23 GMT 2023 - 12.9K bytes - Viewed (0) -
callbacks/associations.go
return func(db *gorm.DB) { if db.Error == nil && db.Statement.Schema != nil { selectColumns, restricted := db.Statement.SelectAndOmitColumns(create, !create) // Save Belongs To associations for _, rel := range db.Statement.Schema.Relationships.BelongsTo { if v, ok := selectColumns[rel.Name]; (ok && !v) || (!ok && restricted) { continue } setupReferences := func(obj reflect.Value, elem reflect.Value) {
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Tue Apr 11 03:06:13 GMT 2023 - 14.3K bytes - Viewed (0) -
callbacks/update.go
db.Statement.ReflectValue = db.Statement.ReflectValue.Elem() } if dest, ok := db.Statement.Dest.(map[string]interface{}); ok { for _, rel := range db.Statement.Schema.Relationships.BelongsTo { if _, ok := dest[rel.Name]; ok { db.AddError(rel.Field.Set(db.Statement.Context, db.Statement.ReflectValue, dest[rel.Name])) } } } } } } // BeforeUpdate before update hooks
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Mon Mar 18 05:44:55 GMT 2024 - 9.4K bytes - Viewed (1) -
tests/update_belongs_to_test.go
. "gorm.io/gorm/utils/tests" ) func TestUpdateBelongsTo(t *testing.T) { user := *GetUser("update-belongs-to", Config{}) if err := DB.Create(&user).Error; err != nil { t.Fatalf("errors happened when create: %v", err) } user.Company = Company{Name: "company-belongs-to-association"} user.Manager = &User{Name: "manager-belongs-to-association"} if err := DB.Save(&user).Error; err != nil {
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Thu Jul 14 06:55:54 GMT 2022 - 1.6K bytes - Viewed (0) -
tests/associations_belongs_to_test.go
DB.Model(&users).Association("Manager").Append( GetUser("manager-slice-belongs-to-1", Config{}), GetUser("manager-slice-belongs-to-2", Config{}), GetUser("manager-slice-belongs-to-3", Config{}), ) AssertAssociationCount(t, users, "Manager", 3, "After Append") if err := DB.Model(&users).Association("Manager").Append( GetUser("manager-slice-belongs-to-test-1", Config{}), ).Error; err == nil {
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Mon Oct 30 09:15:49 GMT 2023 - 9.3K bytes - Viewed (0) -
utils/tests/models.go
package tests import ( "database/sql" "time" "gorm.io/gorm" ) // User has one `Account` (has one), many `Pets` (has many) and `Toys` (has many - polymorphic) // He works in a Company (belongs to), he has a Manager (belongs to - single-table), and also managed a Team (has many - single-table) // He speaks many languages (many to many) and has many friends (many to many - single-table) // His pet also has one Toy (has one - polymorphic)
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Fri Dec 15 08:36:08 GMT 2023 - 2.1K bytes - Viewed (0) -
internal/disk/root_disk.go
// You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. package disk import "runtime" // IsRootDisk returns if diskPath belongs to root-disk, i.e the disk mounted at "/" func IsRootDisk(diskPath string, rootDisk string) (bool, error) { if runtime.GOOS == "windows" { // On windows this function is not implemented. return false, nil }
Go - Registered: Sun Apr 21 19:28:08 GMT 2024 - Last Modified: Tue Jun 01 21:59:40 GMT 2021 - 1.1K bytes - Viewed (0)