Skip to main content

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

AttributeTypeDescription
iduuid.UUID = uuid.uuid4Unique identifier for the user record, automatically generated as a UUID to serve as the primary key.
hashed_passwordstrThe salted and hashed representation of the user's password used for secure authentication.
created_at`datetimeNone` = get_datetime_utc
itemslist["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

NameTypeDescription
iduuid.UUID = uuid.uuid4()The unique identifier for the user.
hashed_passwordstringThe hashed security password for the user account.
created_at`datetimeNone` = get_datetime_utc()
itemslist[[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

TypeDescription
uuid.UUIDA 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

TypeDescription
stringThe 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

TypeDescription
`datetimenull`

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

TypeDescription
list[[Item](item.md?sid=app_models_item)]A list of Item instances associated with the user via a database relationship.