Model
Understanding Models in RestBI
A Model
is a crucial part of how you define, organize, and manage your business data. It encapsulates everything from your database connections, tables, joins, formulas, and filters into a single, cohesive unit. Models allow you to define the relationships between various data elements, making it easier to generate and execute complex queries on your data.
Models act as the blueprint of your data, defining how the different pieces of information in your database relate to each other. They are essential for organizing your data into meaningful structures that can be used to generate insights and reports.
Key Components of the Model
Connection: Defines how RestBI connects to your database. This includes details like the database type, host, port, and credentials.
Joins: Joins define the relationships between tables, used to generate queries across multiple tables.
Formulas: Formulas allow you to create calculated fields based on existing columns or other formulas. They can be used to perform aggregations, calculations, and transformations on your data.
Filters: Filters are conditions applied to your data to narrow down the results returned by your queries.
Example
Model Reference
id
A unique identifier for the model.
name
The internal name of the model used in the application.
displayName
The user-friendly name for the model, often displayed in UIs.
connection
A Connection
object that defines how the model connects to a specific database.
tables
An array of Table
objects representing the tables or views in the database that are part of this model.
joins
An array of Join
objects that define relationships between the tables in the model.
formulas
An array of Formula
objects that define calculated fields or expressions within the model.
filters
An array of Filter
objects that define reusable filters for queries.
Where Can Models Be Stored?
RestBI is designed to be highly flexible, allowing you to store your models wherever you prefer. Typically, models are stored as code in your version-controlled repository (e.g., GitHub, GitLab). This approach allows you to manage your models just like any other part of your codebase, enabling collaboration, version tracking, and rollbacks.
By storing models as code, you can:
Easily integrate models into your CI/CD pipeline.
Track changes over time and roll back to previous versions if needed.
Collaborate with team members using version control systems.
Keep your models and data logic consistent across different environments.
Further Reading
Last updated