You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
First of all thanks for the library. It's quite handy for building complex queries.
I have a use case that I can't produce. I am building keyset pagination and what I need to achieve is the following:
In the models where I need the pagination I pass the pagination struct. So for example in the product model I have this:
And this is the the pagination struct which needs to "paginate" the query.
type Pagination struct {
ID *uint64 `json:"ID" schema:"ID"`
PerPage int64 `json:"perPage" schema:"perPage"`
Direction string `json:"direction" schema:"direction"`
PK string
Env *env.Env
}
func (p *Pagination) Paginate(query *goqu.Dataset) *goqu.Dataset {
order := query.GetClauses().Order
if order != nil {
query.ClearOrder()
}
query = query.Order(p.GetOrder())
if order != nil {
fmt.Printf("%+v\n", order)
//orderedExpression := goqu.OrderedExpression{}
//query = query.GetClauses().Order.Append(order)
//query = query.OrderAppend(order...)
}
if p.ID != nil {
fmt.Printf("%+v\n", order)
query = query.Where(p.GetWhere())
}
query = query.Limit(uint(p.PerPage))
if p.Direction == "down" {
query = p.Invert(query)
}
return query
}
func (p *Pagination) GetOrder() goqu.OrderedExpression {
if p.Direction == "up" {
return goqu.I(p.PK).Asc()
} else {
return goqu.I(p.PK).Desc()
}
}
So in the paginate function I have this piece of code.
order := query.GetClauses().Order
if order != nil {
query.ClearOrder()
}
query = query.Order(p.GetOrder())
if order != nil {
fmt.Printf("%+v\n", order)
//query = query.GetClauses().Order.Append(order)
//query = query.OrderAppend(order...)
}
What I am trying to do is extract the previously set order, add the new order to the *Dataset and append everything else that was previously added. I need this since the order for the primary ID needs to get precedence over the orders of all other columns. Basically what I need is OrderPrepend function which I can't find in the library.
I think I need the following function exposed as public to achieve that. What do you suggest ?
Hi.
First of all thanks for the library. It's quite handy for building complex queries.
I have a use case that I can't produce. I am building keyset pagination and what I need to achieve is the following:
In the models where I need the pagination I pass the pagination struct. So for example in the product model I have this:
And this is the the pagination struct which needs to "paginate" the query.
So in the paginate function I have this piece of code.
What I am trying to do is extract the previously set order, add the new order to the *Dataset and append everything else that was previously added. I need this since the order for the primary ID needs to get precedence over the orders of all other columns. Basically what I need is OrderPrepend function which I can't find in the library.
I think I need the following function exposed as public to achieve that. What do you suggest ?
The text was updated successfully, but these errors were encountered: