jkwchui

jkwchui

I am learning AshSqlite and thought there is value in writing a tutorial, where one goes end-to-end in creating the .sqlite, load some data, define the Resources, and finally packaging the application (let’s call it Facts) as a dependency for other applications (let’s call it Consumer). The last step is where I am stuck. (These are probably general Elixir-Ecto questions.)

In Facts, the created sqlite lives inside priv/ as ./priv/facts.sqlite. It is made available to Exqlite inside config.exs. This works fine while developing Facts.

However, when Facts is used as a dependency, its configuration is not brought in.


Question 1: is there a different place inside Facts where the database connections can be configured? Ideally libraries using Facts would be completely oblivious to how the function calls return values, and that it is included the same {:facts, "~> 1.0"} as any other deps.


To get around this temporarily, I pasted the configuration from Facts into Consumer, which I thought was the wrong move. But obviously ./priv/facts.sqlite isn’t available now. So I thought I could point to the database with

"#{:code.priv_dir(:facts)}/priv/facts.sqlite"`

but this doesn’t work because config happens before compile and :code.priv_dir/1 always returns {:error, "bad name"}.


Question 2: how could one point to the innards of a dependency inside config?

First Post! Switch mode

zachdaniel

zachdaniel

Creator of Ash

Question 1

I believe you can put this kind of information in the init/2 callback of the repo module in question:

Question 2

This is a good question, and I’m not actually sure that you can? As you said, :code.priv_dir(:facts) doesn’t work in that context. Do you have that same experience if its in runtime.exs?

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New

Other Trending Topics Top

ancatrusca
New BEAM There, Done That with Maxim Kharchenko, creator of Ling - not a BEAM fork, a clean Erlang VM implementation running on Xen with ...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement