// OrderBy adds the sort fields into query scope. By default field is ordered ascending. In order to sort descending
// add '-' before the field name i.e. '-id'. The order of the fields relates to the significance of the sorting order.
// Allowed fields to sort:
//  - ID
//  - ID
//  - CreatedAt
//  - Title
//  - TopPostID
OrderBy adds the sort fields into query scope. By default field is ordered ascending. In order to sort descending
add '-' before the field name i.e. '-id'. The order of the fields relates to the significance of the sorting order.
Allowed fields to sort:
- ID
- ID
- CreatedAt
- Title
- TopPostID
// OrderBy adds the sort fields into query scope . By default field is ordered ascending . In order to sort descending // add ' - ' before the field name i . e . ' - id ' . The order of the fields relates to the significance of the sorting order . // Allowed fields to sort : // - ID // - ID // - CreatedAt // - Title // - TopPostID
func (b *blogsQueryBuilder) OrderBy(fields ...string) *blogsQueryBuilder {
	if b.err != nil {
		return b
	}
	sortFields := make([]query.Sort, len(fields))
	for i, field := range fields {
		if len(field) == 0 {
			b.err = errors.Wrap(mapping.ErrInvalidModelField, "cannot set sorting order for an empty field for model: '_Blogs'")
			return b
		}
		var order query.SortOrder
		if field[0] == '-' {
			order = query.DescendingOrder
			field = field[1:]
		}
		structField, ok := NRN_Blogs.Model.FieldByName(field)
		if !ok {
			b.err = errors.Wrapf(mapping.ErrInvalidModelField, "field: '%s' is not valid for model: '_Blogs'", field)
			return b
		}
		sortFields[i] = query.SortField{StructField: structField, SortOrder: order}
	}
	b.builder.OrderBy(sortFields...)
	return b
}
func ( b * blogsQueryBuilder ) OrderBy ( fields ... string ) * blogsQueryBuilder { if b . err != nil { return b } sortFields := make ( [ ] query . Sort , len ( fields ) ) for i , field := range fields { if len ( field ) == 0 { b . err = errors . Wrap ( mapping . ErrInvalidModelField , " " ) return b } var order query . SortOrder if field [ 0 ] == '-' { order = query . DescendingOrder field = field [ 1 : ] } structField , ok := NRN_Blogs . Model . FieldByName ( field ) if ! ok { b . err = errors . Wrapf ( mapping . ErrInvalidModelField , " " , field ) return b } sortFields [ i ] = query . SortField { StructField : structField , SortOrder : order } } b . builder . OrderBy ( sortFields ... ) return b }
OrderBy adds the sort fields into query scope.
OrderBy adds the sort fields into query scope .