-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add limit and offset to QueryBuilder, mild refactoring (#284)
* fix typo "include" => "extend" * refactor builder assemblers * add limit and offset * add limit and offset spec * remove SQLBuilder
- Loading branch information
Showing
6 changed files
with
122 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
# DSL to be included into a model | ||
# DSL to be extended into a model | ||
# To activate, simply | ||
# | ||
# class Model < Granite::Base | ||
# include Query::BuilderMethods | ||
# extend Query::BuilderMethods | ||
# end | ||
module Granite::Query::BuilderMethods | ||
def __builder | ||
Builder(self).new | ||
end | ||
|
||
def count : Executor::Value(self, Int64) | ||
__builder.count | ||
end | ||
|
||
def where(**match_data) : Builder | ||
__builder.where **match_data | ||
end | ||
|
||
def first : self? | ||
__builder.first | ||
end | ||
|
||
def first(n : Int32) : Executor::List(self) | ||
__builder.first n | ||
end | ||
delegate where, count, order, offset, limit, first, to: __builder | ||
end |