User
This class represents a user entity within the database, serving as a data model for authentication and ownership. It manages core user attributes including a unique identifier, hashed credentials, and creation timestamps, while maintaining a one-to-many relationship with associated items.
Attributes
| Attribute | Type | Description |
|---|---|---|
| id | uuid.UUID = uuid.uuid4 | Unique identifier for the user record, automatically generated as a UUID to serve as the primary key. |
| hashed_password | str | The salted and hashed representation of the user's password used for secure authentication. |
| created_at | `datetime | None` = get_datetime_utc |
| items | list["Item"] | A list of Item instances owned by the user, which are automatically deleted if the user is removed. |
Constructor
Signature
def User(
id: uuid.UUID = uuid.uuid4(),
hashed_password: string,
created_at: datetime | None = get_datetime_utc(),
items: list[[Item](item.md?sid=app_models_item)] = []
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| id | uuid.UUID = uuid.uuid4() | The unique identifier for the user. |
| hashed_password | string | The hashed security password for the user account. |
| created_at | `datetime | None` = get_datetime_utc() |
| items | list[[Item](item.md?sid=app_models_item)] = [] | A list of items owned by the user. |
Methods
id()
def id() - > uuid.UUID
The unique identifier for the user record, automatically generated using UUID4.
Returns
| Type | Description |
|---|---|
uuid.UUID | A unique UUID serving as the primary key. |
hashed_password()
def hashed_password() - > string
The salted and hashed representation of the user's password for secure authentication.
Returns
| Type | Description |
|---|---|
string | The cryptographic hash of the user's password. |
created_at()
def created_at() - > datetime | null
The timestamp indicating when the user account was created, stored in UTC with timezone information.
Returns
| Type | Description |
|---|---|
| `datetime | null` |
items()
def items() - > list[[Item](item.md?sid=app_models_item)]
A collection of Item objects owned by this user, which are automatically deleted if the user is removed.
Returns
| Type | Description |
|---|---|
list[[Item](item.md?sid=app_models_item)] | A list of Item instances associated with the user via a database relationship. |