Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 19 of 19 for owner_id (0.16 sec)

  1. docs/en/docs/tutorial/sql-databases.md

        `Item(**item.dict())`
    
        And then we pass the extra keyword argument `owner_id` that is not provided by the Pydantic *model*, with:
    
        `Item(**item.dict(), owner_id=user_id)`
    
    ## Main **FastAPI** app
    
    And now in the file `sql_app/main.py` let's integrate and use all the other parts we created before.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 29.6K bytes
    - Viewed (0)
  2. docs/zh/docs/tutorial/sql-databases.md

        `item.dict()`
    
        然后我们将dict的键值对 作为关键字参数传递给 SQLAlchemy `Item`:
    
        `Item(**item.dict())`
    
        然后我们传递 Pydantic模型未提供的额外关键字参数`owner_id`:
    
        `Item(**item.dict(), owner_id=user_id)`
    
    ## 主**FastAPI**应用程序
    
    现在在`sql_app/main.py`文件中 让我们集成和使用我们之前创建的所有其他部分。
    
    ### 创建数据库表
    
    以非常简单的方式创建数据库表:
    
    === "Python 3.9+"
    
        ```Python hl_lines="7"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 27K bytes
    - Viewed (0)
  3. docs/en/docs/how-to/sql-databases-peewee.md

        It will automatically add an `id` attribute as an integer to be the primary key.
    
        It will chose the name of the tables based on the class names.
    
        For the `Item`, it will create an attribute `owner_id` with the integer ID of the `User`. But we don't declare it anywhere.
    
    ## Create the Pydantic models
    
    Now let's check the file `sql_app/schemas.py`.
    
    !!! tip
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 16 13:23:25 GMT 2024
    - 23.6K bytes
    - Viewed (1)
  4. docs/em/docs/tutorial/sql-databases.md

        `item.dict()`
    
         & ⤴️ 👥 🚶‍♀️ `dict`'Ⓜ 🔑-💲 👫 🇨🇻 ❌ 🇸🇲 `Item`, ⏮️:
    
        `Item(**item.dict())`
    
         & ⤴️ 👥 🚶‍♀️ ➕ 🇨🇻 ❌ `owner_id` 👈 🚫 🚚 Pydantic *🏷*, ⏮️:
    
        `Item(**item.dict(), owner_id=user_id)`
    
    ## 👑 **FastAPI** 📱
    
    & 🔜 📁 `sql_app/main.py` ➡️ 🛠️ & ⚙️ 🌐 🎏 🍕 👥 ✍ ⏭.
    
    ### ✍ 💽 🏓
    
    📶 🙃 🌌 ✍ 💽 🏓:
    
    === "🐍 3️⃣.6️⃣ & 🔛"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 25.2K bytes
    - Viewed (1)
  5. schema/relationship_test.go

    						FieldSchema: "Toy",
    						Polymorphic: Polymorphic{ID: "owner_id", Type: "Type", Value: "users"},
    						References: []Reference{
    							{ForeignKey: "Type", ForeignSchema: "Toy", PrimaryValue: "users"},
    						},
    					},
    				},
    			},
    		})
    	})
    
    	t.Run("has many", func(t *testing.T) {
    		type Toy struct {
    			ID        int
    			Name      string
    			OwnerID   int
    			OwnerType string
    		}
    
    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)
  6. docs/em/docs/how-to/sql-databases-peewee.md

    {!../../../docs_src/sql_databases_peewee/sql_app/models.py!}
    ```
    
    !!! tip
        🏒 ✍ 📚 🎱 🔢.
    
        ⚫️ 🔜 🔁 🚮 `id` 🔢 🔢 👑 🔑.
    
        ⚫️ 🔜 ⚒ 📛 🏓 ⚓️ 🔛 🎓 📛.
    
         `Item`, ⚫️ 🔜 ✍ 🔢 `owner_id` ⏮️ 🔢 🆔 `User`. ✋️ 👥 🚫 📣 ⚫️ 🙆.
    
    ## ✍ Pydantic 🏷
    
    🔜 ➡️ ✅ 📁 `sql_app/schemas.py`.
    
    !!! tip
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 19.2K bytes
    - Viewed (0)
  7. utils/tests/models.go

    	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
    }
    
    type Company struct {
    	ID   int
    	Name 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)
  8. tests/helper_test.go

    		}
    	}
    
    	AssertObjEqual(t, pet, expect, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Name")
    
    	AssertObjEqual(t, pet.Toy, expect.Toy, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "Name", "OwnerID", "OwnerType")
    
    	if expect.Toy.Name != "" && expect.Toy.OwnerType != "pets" {
    		t.Errorf("toys's OwnerType, expect: %v, got %v", "pets", expect.Toy.OwnerType)
    	}
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  9. schema/relationship.go

    //
    //	type User struct {
    //	  Toys []Toy `gorm:"polymorphic:Owner;"`
    //	}
    //	type Pet struct {
    //	  Toy Toy `gorm:"polymorphic:Owner;"`
    //	}
    //	type Toy struct {
    //	  OwnerID   int
    //	  OwnerType string
    //	}
    func (schema *Schema) buildPolymorphicRelation(relation *Relationship, field *Field) {
    	polymorphic := field.TagSettings["POLYMORPHIC"]
    
    	relation.Polymorphic = &Polymorphic{
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
Back to top