Create initial user if User table is empty. Also make model.QueryOptions compatible with rest.QueryOptions

This commit is contained in:
Deluan
2020-01-19 22:36:15 -05:00
parent 2ab0cecd48
commit 491bfb1f69
11 changed files with 130 additions and 38 deletions
+6 -6
View File
@@ -16,14 +16,14 @@ func (r *sqlRepository) newQuery(options ...model.QueryOptions) orm.QuerySeter {
if len(options) > 0 {
opts := options[0]
q = q.Offset(opts.Offset)
if opts.Size > 0 {
q = q.Limit(opts.Size)
if opts.Max > 0 {
q = q.Limit(opts.Max)
}
if opts.SortBy != "" {
if opts.Desc {
q = q.OrderBy("-" + opts.SortBy)
if opts.Sort != "" {
if opts.Order == "desc" {
q = q.OrderBy("-" + opts.Sort)
} else {
q = q.OrderBy(opts.SortBy)
q = q.OrderBy(opts.Sort)
}
}
}