Request for views and functions

How can I query non-model views or table-returning functions using Ecto? In my case, the function (with one argument) returns the same columns as one of my models and it will just need to be read only.

+3


source to share


1 answer


You can tell Ecto to load data from any view or table like this:

from c in "special_comments(1)"

      

If you want to load this into a specific module, you can do:



from c in {"special_comments(1)", MyApp.Comment}

      

And you should be good to go!

+2


source