Skip to content

Changeset

changeset

Classes:

  • Changeset

    The Changeset includes multiple column changes for an object modified on a remote server via frontend or API.

Changeset dataclass

Changeset(
    table: type[BaseModel],
    id: str,
    values: dict[Column, str | int | float | bool | None],
)

The Changeset includes multiple column changes for an object modified on a remote server via frontend or API.

The changeset contains the table that was modified, the unique id of the object as well as a dictionary of column changes. With this object, it is possible to retrieve the original value from the database for easier handling via the from_orm method.

It's important to note that the changeset does not contain the original values of the columns, as well as the information if the row is new or updated. It is possible, however, to retrieve this information by loading a local copy of the database.

The changeset is also only available from the moment the budget was initialized.

Parameters:

  • table

    (type[BaseModel]) –

    The SQLModel reference to the table hosting the data.

  • id

    (str) –

    The unique id of the row that was inserted or updated.

  • values

    (dict[Column, Union[str, int, float, bool, None]]) –

    The list of values that were updated on the remote server, using column names as keys.

Methods:

  • from_orm

    Returns the modifiable object from the database related to this change.

from_orm

from_orm(s: Session) -> BaseModel | None

Returns the modifiable object from the database related to this change.

Source code in actual/utils/changeset.py
def from_orm(self, s: Session) -> BaseModel | None:
    """Returns the modifiable object from the database related to this change."""
    query = select(self.table).where(self.table.id == self.id)
    return s.exec(query).one_or_none()