github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/processors/query/factory-order-by-impl.go (about)

     1  /*
     2   * Copyright (c) 2021-present unTill Pro, Ltd.
     3   */
     4  
     5  package queryprocessor
     6  
     7  import (
     8  	"fmt"
     9  
    10  	coreutils "github.com/voedger/voedger/pkg/utils"
    11  )
    12  
    13  func NewOrderBy(data coreutils.MapObject) (IOrderBy, error) {
    14  	field, err := data.AsStringRequired("field")
    15  	if err != nil {
    16  		return nil, fmt.Errorf("orderBy: %w", err)
    17  	}
    18  	desc, _, err := data.AsBoolean("desc")
    19  	if err != nil {
    20  		return nil, fmt.Errorf("orderBy: %w", err)
    21  	}
    22  	return orderBy{
    23  		field: field,
    24  		desc:  desc,
    25  	}, nil
    26  }
    27  
    28  type orderBy struct {
    29  	field string
    30  	desc  bool
    31  }
    32  
    33  func (o orderBy) Field() string { return o.field }
    34  func (o orderBy) IsDesc() bool  { return o.desc }