Finish resource search wf handlers
* Remove page cursor from response, * correctly return totals.
This commit is contained in:
@@ -236,9 +236,8 @@ type (
|
||||
}
|
||||
|
||||
recordsSearchResults struct {
|
||||
Records []*types.Record
|
||||
Total uint64
|
||||
PageCursor string
|
||||
Records []*types.Record
|
||||
Total uint64
|
||||
}
|
||||
)
|
||||
|
||||
@@ -328,11 +327,6 @@ func (h recordsHandler) Search() *atypes.Function {
|
||||
Description: "Total items that satisfy given conditions.\n\nNeeds to be explicitly requested with incTotal argument",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
Name: "pageCursor",
|
||||
Types: []string{"String"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
@@ -421,19 +415,6 @@ func (h recordsHandler) Search() *atypes.Function {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// converting results.PageCursor (string) to String
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("String").Cast(results.PageCursor); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "pageCursor", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ func (h recordsHandler) search(ctx context.Context, args *recordsSearchArgs) (re
|
||||
f.Limit = uint(args.Limit)
|
||||
}
|
||||
|
||||
results.Records, _, err = h.rec.Find(ctx, f)
|
||||
var auxf types.RecordFilter
|
||||
results.Records, auxf, err = h.rec.Find(ctx, f)
|
||||
results.Total = uint64(auxf.Total)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ functions:
|
||||
<<: *rvRecord
|
||||
isArray: true
|
||||
total: *rvTotal
|
||||
pageCursor: *rvPageCursor
|
||||
|
||||
first:
|
||||
meta:
|
||||
|
||||
Reference in New Issue
Block a user