I am a complete novice to Elixir, Phoenix and functional programming itself. I am quite overwhelmed by the whole file structure you get when starting with Phoenix. To get to know it a little better, I want to do the following:
I have a Model called
Document. It holds some metadata for files that exist locally on my machine (field “filename” in the model). I also added a config value
documents_path where those documents are supposedly stored. On startup (or ideally in a set interval), I want to verify whether the Documents in the database and the local files match up (does the file locally exist? If not, we should get rid of the database entry).
I have several questions now:
- Where do I put my function (lets assume its named
verify_document_cache). Do I put it in the
1.1 If not, where do I put it and how do I gain access to the
Reposo I can call
Repo.all, or do I create a helper for that somewhere else?
- Is it the “correct” way to run it from the
lib/my_app.exfile as stackoverflow suggests?
2.1 How do I “include” the DocumentController (or whereever I will implement the function)? I tried
require Myapp.DocumentControlleror just
require DocumentControllerbut the compiler complains that they do not exist.
- how do I do stuff in intervals?
Thank you for your answers.