From 90042da9327c1a7e371655eaff404ca65e5ac196 Mon Sep 17 00:00:00 2001 From: leandrofars Date: Thu, 25 Apr 2024 18:07:31 -0300 Subject: [PATCH] feat(api): return user creation date --- backend/services/controller/internal/api/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/services/controller/internal/api/user.go b/backend/services/controller/internal/api/user.go index 6800d40..542264a 100644 --- a/backend/services/controller/internal/api/user.go +++ b/backend/services/controller/internal/api/user.go @@ -9,6 +9,7 @@ import ( "github.com/leandrofars/oktopus/internal/api/auth" "github.com/leandrofars/oktopus/internal/db" "github.com/leandrofars/oktopus/internal/utils" + "go.mongodb.org/mongo-driver/bson/primitive" ) func (a *Api) retrieveUsers(w http.ResponseWriter, r *http.Request) { @@ -20,6 +21,11 @@ func (a *Api) retrieveUsers(w http.ResponseWriter, r *http.Request) { } for _, x := range users { + objectID, ok := x["_id"].(primitive.ObjectID) + if ok { + creationTime := objectID.Timestamp() + x["createdAt"] = creationTime.Format("02/01/2006") + } delete(x, "password") }