How to pass `opts` to Repo module functions?

Example:
opts = [settings: [final: 1]]
Repo.get(User, id, opts)
opts = [settings: [final: 1]]
Repo.get(User, id, opts)
Can it be passed through resource actions?
5 Replies
ZachDaniel
ZachDaniel2mo ago
There is no current way What option do you want to pass
JVMartyns
JVMartynsOP2mo ago
opts = [settings: [final: 1]]
opts = [settings: [final: 1]]
This option tells the ClickHouse database to merge the partitions and return the latest version of the table data. I'm trying to create a DataLayer for ClickHouse, but I don't know how to make these options reach the functions in the Repo module.
ZachDaniel
ZachDaniel2mo ago
You can use the query context
JVMartyns
JVMartynsOP2mo ago
Here I have a "tasks" table of type ReplacingMergeTree in Clickhouse. As you can see in image_1, we have two versions of the same table data. In image_2, after passing settings final=1, Clickhouse merges the partitions and returns the latest version of the data. image_3 presents a helper; this is how I managed to send the opts from an action to the Repo module. In image_4, I'm merging the default opts with the opts I passed previously. Note: There will probably still be many changes, but for now I'm making progress.
Fetching data from the "tasks" table in Clickhouse. The query returned the data without merging the partitions. So we can see two versions of the same data.
Fetching data from the "tasks" table in Clickhouse, this time passing the `settings final=1` options. The query returned the latest versions of the data.
Fetching data from the "tasks" table in Clickhouse, this time passing the `settings final=1` options. The query returned the latest versions of the data.
In the run_query function in the DataLayer the options are passed to the Repo module.
JVMartyns
JVMartynsOP2mo ago
Thanks

Did you find this page helpful?