-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from stephenafamo/function-fix
Rework function starter for more flexibility
- Loading branch information
Showing
24 changed files
with
370 additions
and
238 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package fm | ||
|
||
import ( | ||
"github.com/stephenafamo/bob" | ||
"github.com/stephenafamo/bob/clause" | ||
"github.com/stephenafamo/bob/dialect/mysql/dialect" | ||
"github.com/stephenafamo/bob/mods" | ||
) | ||
|
||
func Distinct() bob.Mod[*dialect.Function] { | ||
return mods.QueryModFunc[*dialect.Function](func(f *dialect.Function) { | ||
f.Distinct = true | ||
}) | ||
} | ||
|
||
func OrderBy(e any) dialect.OrderBy[*dialect.Function] { | ||
return dialect.OrderBy[*dialect.Function](func() clause.OrderDef { | ||
return clause.OrderDef{ | ||
Expression: e, | ||
} | ||
}) | ||
} | ||
|
||
func Filter(e ...any) bob.Mod[*dialect.Function] { | ||
return mods.QueryModFunc[*dialect.Function](func(f *dialect.Function) { | ||
f.Filter = append(f.Filter, e...) | ||
}) | ||
} | ||
|
||
func Over() dialect.WindowMod[*dialect.Function] { | ||
m := dialect.WindowMod[*dialect.Function]{} | ||
m.WindowChain = &dialect.WindowChain[*dialect.WindowMod[*dialect.Function]]{ | ||
Wrap: &m, | ||
} | ||
return m | ||
} |
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
Oops, something went wrong.