Workspace
In this page, I'll lay out all the methods available on the workspace class
💡 TIP
As mentioned in the introduction, Workspace
class is a table and any sql operations can be performed using sqlalchemy
attr
description
The description of the workspace
description: Mapped[str] = mapped_column(default="")
attr
parent_workspace
The parent workspace of the workpsace
parent_workspace: Mapped[Optional["Workspace"]] = relationship(
"Workspace",
back_populates="workspaces",
remote_side=[id],
)
attr
workspaces
The child workspaces of the workspace
workspaces: Mapped[List["Workspace"]] = relationship(
"Workspace",
back_populates="parent_workspace",
cascade="all",
order_by="Workspace.order_index",
)
attr
todos
The todos for the workspace
todos: Mapped[List["Todo"]] = relationship(
"Todo",
back_populates="parent_workspace",
cascade="all, delete-orphan",
order_by="Todo.order_index",
)
classmethod
from_id
from_id(id: str | int) -> Workspace
Returns the workspace object with the given id
Parameters:
Param | Default | Description |
---|---|---|
id | The id of the workspace object you want to get |
Returns:
Type | Default | Description |
---|---|---|
Self | The workspace object |
Raises:
Type | Default | Description |
---|---|---|
ValueError | If an invalid ID is passed |
classmethod
all
all() -> List[Workspace]
Returns all the workspaces from the database
Returns:
Type | Default | Description |
---|---|---|
List[Self] | List of the workspaces present in the database |
property
parent
parent -> Workspace
Returns the parent of the workspace object
Returns:
Type | Default | Description |
---|---|---|
Workspace | The parent of the workspace object |
property
nest_level
nest_level -> int
Returns the nested level from the root
Returns:
Type | Default | Description |
---|---|---|
int | Depth of the nesting |
method
siblings
siblings() -> List[Workspace]
Returns the siblings for the workspace (including self)
Returns:
Type | Default | Description |
---|---|---|
List[Self] | List of the siblings (including self) |
method
sort_siblings
sort_siblings()
Sorts all the siblings (by description)
method
add_todo
add_todo() -> Todo
Adds a todo to the workspace object
Returns:
Type | Default | Description |
---|---|---|
Todo | The newly added todo |
method
add_workspace
add_workspace() -> Workspace
Adds a child workspace to the workspace object
Returns:
Type | Default | Description |
---|---|---|
Workspace | The newly added Workspace |
method
shift_down
Shifts the workspace down by one index (Nothing happens if its the first workspace)
shift_down()
method
shift_up
Shifts the workspace down by one index (Nothing happens if its the last workspace)
shift_up()
method
save
Saves any modifications done on the attributes to the database
save()