Skip to content

Reference

Reference model to store references from one object to another

amsdal_utils.models.data_models.reference.ReferenceData

Bases: Address

amsdal_utils.models.data_models.reference.Reference

Bases: QueryableMixin, BaseModel

Represents a reference to an object/record.

Attributes: ref (ReferenceData): The reference to the object/record.

set_address classmethod

set_address(address)

Validates and sets the address for the reference data.

Args: address (str | Address | dict[str, str]): The address to set. It can be a string, an Address instance, or a dictionary.

Returns: ReferenceData: The validated reference data.

Raises: ValueError: If the input is not a valid dictionary or instance of ReferenceData. ValueError: If the class version is not provided or is set to Versions.ALL. ValueError: If the object version is set to Versions.ALL.

model_dump

model_dump(**kwargs)

Dumps the model data to a dictionary.

Args: **kwargs (Any): Additional keyword arguments to pass to the model dump.

Returns: dict[str, Any]: A dictionary representation of the model data.

to_query

to_query(prefix='')

Converts the reference data to a query object. Args: prefix (str): The prefix to use for the query fields. Defaults to an empty string. Returns: Q: The query object representing the reference data.

Code Examples

Load reference

from amsdal_models.classes.helpers.reference_loader import ReferenceLoader

loaded_object = ReferenceLoader(some_reference).load_reference()