Assette Data Blocks the fundamental components within the Assette data stack and serve as the primary means of fetching and providing data to other layers, such as Data Objects. They are responsible for retrieving data from various sources, performing initial transformations, and supplying data that can be further processed and presented to end-users through Smart Pages and Smart Docs.
Key Responsibilities of Data Blocks #
The Data Blocks layer has several critical responsibilities:
- Data Retrieval from Sources: Data Blocks connect to data sources like databases or APIs to fetch raw data. They execute queries or API calls, possibly using parameters to filter or customize the data retrieval.
- Initial Data Transformation: While primarily focused on data retrieval, Data Blocks can perform basic data transformations or calculations needed before passing the data to the next layer.
- Handling Parameters: Data Blocks accept parameters—referred to as Request Parameter which influence how data is fetched and processed. These parameters can be used to filter data, specify conditions, or modify queries.
- Providing Options for Data Settings: They can enrich Data Settings by providing information on possible options, default values, and dependencies. This improves the user experience in Authoring Tools by offering selectable options to content authors.
Interaction with Data Objects #
Data Blocks work closely with Data Objects to ensure seamless data flow and manipulation within the Assette platform:
- Passing Data to Data Objects: The data retrieved and initially processed by Data Blocks is supplied to Data Objects, which further implement business and presentation logic.
- Receiving Parameters from Data Objects: Data Objects can pass parameters down to Data Blocks. These parameters might be used in database queries or API calls to filter the output data set. Data Objects refer to these parameters as Data Settings, as discussed below.
- Enabling Dynamic Content: By accepting parameters and providing options, Data Blocks enable Data Objects to produce dynamic content that can be customized by business users or content authors.
Data Block Request Parameters #
Request Parameters play a crucial role in how Data Blocks operate:
- Customization of Data Retrieval: Parameters passed as Data Settings allow Data Blocks to perform customized data retrieval operations. For example, they can fetch data for a specific date range or a particular category.
- Enhancing User Experience: By providing possible options and default values for Data Settings, Data Blocks help create a more intuitive and user-friendly interface in the Authoring Tools.
- Dependencies and Conditional Logic: Data Settings can be configured to depend on the selected values of other settings. This dependency ensures that content authors are presented with relevant options based on their previous selections.
Providing Options to Content Authors #
Data Blocks can supply key-value pairs used as options in Data Settings:
- Defined Options: The Data Block author can define a set of options directly within the Data Block.
- Dynamic Options from Data Sources: Data Blocks can retrieve options from data sources. For instance, they can execute a query that returns a list of active categories, which are then presented as selectable options to the content author.
- Mapping Output Columns: When providing options from data sources, one output column is mapped to the key, and another column is mapped to the display name (value).
Benefits of Using Data Blocks #
- Reusability: Data Blocks can be designed to be reusable across multiple Data Objects and templates, reducing redundancy and development time.
- Separation of Concerns: By handling data retrieval and initial processing, Data Blocks allow Data Objects to focus on business logic and presentation, leading to cleaner and more maintainable code.
- Flexibility: Parameters and Data Settings enable Data Blocks to be flexible and adaptable to different data retrieval needs without modifying the underlying code.