-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
if _email:
raise HTTPException(
status_code=400, detail="Email already exists!")
else:
# insert to tables
created_person = await PersonRepository.create(**_person.dict())
_users = Users(username=register.username, email=register.email,
password=pwd_context.hash(register.password),
person_id=**created_person.id**)
created_user = await UsersRepository.create(**_users.dict())
_role = await RoleRepository.find_by_role_name("user")
_users_role = UsersRole(users_id=**created_user.id**, role_id=_role.id)
await UsersRoleRepository.create(**_users_role.dict())
This optimizes performance AuthService by omitting the generation of the UUID code, also change in the models pymantic:
class Person(SQLModel, TimeMixin, table=True):
__tablename__ = "person"
id: Optional[**int**] = Field(default=None, primary_key=True, nullable=False)
name: str
birth: date
sex: Sex
profile: str
phone_number: str
users: Optional["Users"] = Relationship(sa_relationship_kwargs={"uselist": False}, back_populates="person")
Duplicate UUID is more complicated, but not impossible with bigdata.
Extra info: https://sqlmodel.tiangolo.com/tutorial/automatic-id-none-refresh/
Metadata
Metadata
Assignees
Labels
No labels