mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 10:54:28 +00:00
fix lists to use different key path
This commit is contained in:
@@ -3,7 +3,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -65,7 +65,7 @@ func (h *Lists) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.Creat
|
|||||||
Items: req.Items,
|
Items: req.Items,
|
||||||
}
|
}
|
||||||
|
|
||||||
key := fmt.Sprintf("%s:%s", tnt, id)
|
key := path.Join("list", tnt, id.String())
|
||||||
rec := store.NewRecord(key, list)
|
rec := store.NewRecord(key, list)
|
||||||
|
|
||||||
if err = store.Write(rec); err != nil {
|
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"
|
tnt = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
key := fmt.Sprintf("%s:%s", tnt, req.Id)
|
key := path.Join("list", tnt, req.Id)
|
||||||
|
|
||||||
// read the specific list
|
// read the specific list
|
||||||
recs, err := store.Read(key)
|
recs, err := store.Read(key)
|
||||||
@@ -133,7 +133,7 @@ func (h *Lists) Update(ctx context.Context, req *pb.UpdateRequest, rsp *pb.Updat
|
|||||||
tnt = "default"
|
tnt = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
key := fmt.Sprintf("%s:%s", tnt, req.List.Id)
|
key := path.Join("list", tnt, req.List.Id)
|
||||||
|
|
||||||
// read the specific list
|
// read the specific list
|
||||||
recs, err := store.Read(key)
|
recs, err := store.Read(key)
|
||||||
@@ -234,7 +234,7 @@ func (h *Lists) Delete(ctx context.Context, req *pb.DeleteRequest, rsp *pb.Delet
|
|||||||
tnt = "default"
|
tnt = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
key := fmt.Sprintf("%s:%s", tnt, req.Id)
|
key := path.Join("list", tnt, req.Id)
|
||||||
|
|
||||||
// read the specific list
|
// read the specific list
|
||||||
recs, err := store.Read(key)
|
recs, err := store.Read(key)
|
||||||
@@ -275,7 +275,7 @@ func (h *Lists) List(ctx context.Context, req *pb.ListRequest, rsp *pb.ListRespo
|
|||||||
tnt = "default"
|
tnt = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
key := fmt.Sprintf("%s:", tnt)
|
key := path.Join("list", tnt) + "/"
|
||||||
|
|
||||||
// Retrieve all of the records in the store
|
// Retrieve all of the records in the store
|
||||||
recs, err := store.Read(key, store.ReadPrefix())
|
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")
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user