Documentation Request: Clarification on How Functions Are called in the background.
Hi,
I was looking through the documentation however I couldn't see a detailed explanation on how the functions are used on my postgres db. It shows that it defines a function with the same name, however I don't know if any extra js code is executed, if it executes on the db or converted to js. After digging through the issues I found this answer to a functions question: #271 (comment 145756958)
In the issue, OP is asking why his function doesn't work.
- Places his function-create code at db/scripts/my_test.sql
- Function does not exist in the database before massive initializes.
- Initializes massive such as:
massive.connectSync({
connectionString,
scripts: './db/scripts'
});
...and @dmfay goes on to explain it this way:
Your script exists as a function in Massive, which, when you call it, executes the SQL in the script - namely, it creates the function in the database. It does not also load the new function into Massive. The first time you make the call to
my_test
massive executes that SQL, and a function is created (or recreated) in the back end. Since Massive loads up database-defined functions at load, it is not loaded as a property of Massive this way.
Having limited knowledge on postgres and massive, the approach of massive was not very clear to me. I learned later that it was not an ORM, but that's not very clear on the docs page for Database Functions and Procedures