From b615906097e5de1dabee233b2d8cfc7d9312cded Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 22 Jun 2024 15:35:58 -0700 Subject: [PATCH] listAll[T] working --- client.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index 85ea2e8..6612495 100644 --- a/client.go +++ b/client.go @@ -125,18 +125,11 @@ func listAll[T any](ctx context.Context, c *Client, db, table string, params url for { resp := map[string]any{} - err := c.get(ctx, db, table, "", params, resp) + err := c.get(ctx, db, table, "", params, &resp) if err != nil { return nil, err } - off, found := resp["offset"] - if !found { - return ret, nil - } - - params.Set("offset", off.(string)) - subresp, err := json.Marshal(resp[key]) if err != nil { return nil, err @@ -144,11 +137,19 @@ func listAll[T any](ctx context.Context, c *Client, db, table string, params url obj := []*T{} - err = json.Unmarshal(subresp, obj) + err = json.Unmarshal(subresp, &obj) if err != nil { return nil, err } ret = append(ret, obj...) + + off, found := resp["offset"] + if !found { + return ret, nil + } + + params.Set("offset", off.(string)) + } }