// 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
//  - Title
//  - Body
//  - Likes
//  - BlogID
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
- Title
- Body
- Likes
- BlogID
// 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 // - Title // - Body // - Likes // - BlogID
func (p *postsQueryBuilder) OrderBy(fields ...string) *postsQueryBuilder {
	if p.err != nil {
		return p
	}
	sortFields := make([]query.Sort, len(fields))
	for i, field := range fields {
		if len(field) == 0 {
			p.err = errors.Wrap(mapping.ErrInvalidModelField, "cannot set sorting order for an empty field for model: '_Posts'")
			return p
		}
		var order query.SortOrder
		if field[0] == '-' {
			order = query.DescendingOrder
			field = field[1:]
		}
		structField, ok := NRN_Posts.Model.FieldByName(field)
		if !ok {
			p.err = errors.Wrapf(mapping.ErrInvalidModelField, "field: '%s' is not valid for model: '_Posts'", field)
			return p
		}
		sortFields[i] = query.SortField{StructField: structField, SortOrder: order}
	}
	p.builder.OrderBy(sortFields...)
	return p
}
func ( p * postsQueryBuilder ) OrderBy ( fields ... string ) * postsQueryBuilder { if p . err != nil { return p } sortFields := make ( [ ] query . Sort , len ( fields ) ) for i , field := range fields { if len ( field ) == 0 { p . err = errors . Wrap ( mapping . ErrInvalidModelField , " " ) return p } var order query . SortOrder if field [ 0 ] == '-' { order = query . DescendingOrder field = field [ 1 : ] } structField , ok := NRN_Posts . Model . FieldByName ( field ) if ! ok { p . err = errors . Wrapf ( mapping . ErrInvalidModelField , " " , field ) return p } sortFields [ i ] = query . SortField { StructField : structField , SortOrder : order } } p . builder . OrderBy ( sortFields ... ) return p }
OrderBy adds the sort fields into query scope.
OrderBy adds the sort fields into query scope .