Creating Models
How to create a model to query a source.
Modelsare how you define the data you want to work with from a given data source. Don't think of a Model as your final result or query set, rather its all the relevant data from which you may query your final result set.
Read more about the rationale behind Modelson its concept page.
Defining a Model
You can define models in two ways, adding a models.yaml
file to the PREEN_CONFIG_PATH
or adding individual model files to the ~/.preen/models
directory. You may save a model file anywhere you'd like, so long as its parent directory is specified by PREEN_MODELS_PATH
Here's an example database
model. Note that column names need to be fully qualified, i.e. users.id instead of id.
Registering a Model with a Source
Consider a simplified https://github.com/hyphasql/hypha/blob/main/docs/concepts/source.md config from the last page, pared down to one data source. You register the users model with the source as follows.
You can now validate and build your models in Preen.
Last updated