Finish resource search wf handlers

* Remove page cursor from response,
* correctly return totals.
This commit is contained in:
Tomaž Jerman
2021-03-23 11:13:00 +01:00
parent dc008af2b4
commit 5d2ff6fe05
11 changed files with 20 additions and 91 deletions
+2 -21
View File
@@ -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
},
}
+3 -1
View File
@@ -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
}
-1
View File
@@ -118,7 +118,6 @@ functions:
<<: *rvRecord
isArray: true
total: *rvTotal
pageCursor: *rvPageCursor
first:
meta: