lapis
lapis copied to clipboard
[Feature Request] Add fields option to relations
Please add fields option to relations.
For example with has_many:
local Users = Model:extend("users", {
relations = {
{"files", has_many = "Files", fields='id, user_id, name' }
}
})
Use case is when working with large blob columns, like large files in the database, we don't want to always fetch the file data column.
Workaround:
Use relations with fetch option or skip it and use include_in because it has the fields option.
@edubart I use include_in and set the fields option. but I get this error:
../luajit/share/lua/5.1/lapis/db/base_model.lua:464: table index is nil
any idea?
@linsir Read the docs of include_in at http://leafo.net/lapis/reference/models.html
I want to note that for this issue I am currently using relations with fields fetch and preload set and doing manual queries inside them.