From 4e9b7bccc9126658f41be9e0969e7f91f507f350 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 20 Feb 2022 12:02:20 +0000 Subject: [PATCH] fix lists to use different key path --- lists/handler/lists.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lists/handler/lists.go b/lists/handler/lists.go index c9620b0..c14b593 100644 --- a/lists/handler/lists.go +++ b/lists/handler/lists.go @@ -3,7 +3,7 @@ package handler import ( "context" "encoding/json" - "fmt" + "path" "time" "github.com/google/uuid" @@ -65,7 +65,7 @@ func (h *Lists) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.Creat Items: req.Items, } - key := fmt.Sprintf("%s:%s", tnt, id) + key := path.Join("list", tnt, id.String()) rec := store.NewRecord(key, list) if err = store.Write(rec); err != nil { @@ -96,7 +96,7 @@ func (h *Lists) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ReadRespo tnt = "default" } - key := fmt.Sprintf("%s:%s", tnt, req.Id) + key := path.Join("list", tnt, req.Id) // read the specific list recs, err := store.Read(key) @@ -133,7 +133,7 @@ func (h *Lists) Update(ctx context.Context, req *pb.UpdateRequest, rsp *pb.Updat tnt = "default" } - key := fmt.Sprintf("%s:%s", tnt, req.List.Id) + key := path.Join("list", tnt, req.List.Id) // read the specific list recs, err := store.Read(key) @@ -234,7 +234,7 @@ func (h *Lists) Delete(ctx context.Context, req *pb.DeleteRequest, rsp *pb.Delet tnt = "default" } - key := fmt.Sprintf("%s:%s", tnt, req.Id) + key := path.Join("list", tnt, req.Id) // read the specific list recs, err := store.Read(key) @@ -275,7 +275,7 @@ func (h *Lists) List(ctx context.Context, req *pb.ListRequest, rsp *pb.ListRespo tnt = "default" } - key := fmt.Sprintf("%s:", tnt) + key := path.Join("list", tnt) + "/" // Retrieve all of the records in the store recs, err := store.Read(key, store.ReadPrefix()) @@ -307,7 +307,7 @@ func (h *Lists) DeleteData(ctx context.Context, request *adminpb.DeleteDataReque return errors.BadRequest(method, "Missing tenant ID") } - keys, err := store.List(store.ListPrefix(request.TenantId)) + keys, err := store.List(store.ListPrefix(path.Join("list", request.TenantId) + "/")) if err != nil { return err }