module Clear::View
Overview
A view is like a read-only model. It has columns and relations It is automatically updated on migration by the migration manager
class MyView
define <<-SQL
SELECT * FROM users, other_views
SQL
depends_of OtherViews
end
Included Modules
- Clear::Model::ClassMethods
- Clear::Model::HasColumns
- Clear::Model::HasRelations
- Clear::Model::HasScope
Defined in:
clear/views/view.crClass Method Summary
Macro Summary
-
scope(name, &block)
A scope allow you to filter in a very human way a set of data.
Instance methods inherited from module Clear::Model::HasColumns
[](x) : Clear::SQL::Any
[],
[]?(x) : Clear::SQL::Any
[]?,
reset(h : Hash(String, _))reset(h : Hash(Symbol, _))
reset(**t : **T) forall T reset, set(h : Hash(String, _))
set(h : Hash(Symbol, _))
set(**t : **T) forall T set, to_h(full = false) to_h, update_h update_h
Class Method Detail
Macro Detail
macro scope(name, &block)
#
A scope allow you to filter in a very human way a set of data.
Usage:
scope("admin") { where({role: "admin"}) }
for example, instead of writing:
User.query.where { (role == "admin") & (active == true) }
You can write:
User.admin.active
Scope can be used for other purpose than just filter (e.g. ordering), but I would not recommend it.