Hello everyone!
I saw in the docs (Add table documentation and Reuse variables and functions with includes in Dataform) you can add table documentation to Dataform by creating a file in the includes/ folder.
Question: Is it possible to organize these files in subfolders inside the includes/ folder? I want to organize the file descriptions, functions, etc by the tables I am working on.
Example:
includes/table_1/docs.js
includes/table_2/docs_2.js
And how should I do the import into my .sqlx file? I tried using the name of the file but this only works if the file is placed directly in the includes/ folder (includes/docs.js). If I add another folder (includes/folder_1/docs.js) I cannot reference the file correctly. I also tried doing the import with the js module but I cannot use the values inside the config{} block for description and columns.
Thank you so much for your help!
I managed to work this approach by using a single file in the /includes folder as a middleware between the file structure I wanted and the tables in /definition.
If it helps someone, here's an example of the file structure I'm using to solve this (if there are any other better ways I'd be glad to receive your comments.)
Example of config_file.js:
const table_1 = { table_config, columns } = require("includes/folder1/file_1.js")
module.exports = {
table_1,
};
Example of file_1.js:
const table_config = {
DESCRIPTION: `DESCRIPTION OF TABLE 1`,
...
};
const columns = {
user_id : `A unique identifier for a user`,
age : `The age of a user`,
...
}
module.exports = {
table_config,
columns
};
With this, I can use it in the .sqlx file as:
config {
type: "table",
name:"table_name",
description: config.table_1.table_config.DESCRIPTION,
columns: config.table_1.columns
}
Hope it may be helpful for someone))