From 20cd83e7ac6296a59ae422f6f5e94cdb51e9a018 Mon Sep 17 00:00:00 2001 From: Nam Huynh Date: Tue, 17 Aug 2021 11:38:27 +0700 Subject: [PATCH] remove field Name --- action_query.go | 1 - action_upsert.go | 6 ++---- find_by_device_id.go | 2 +- model.go | 2 -- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/action_query.go b/action_query.go index c96374e..eec3be5 100644 --- a/action_query.go +++ b/action_query.go @@ -37,7 +37,6 @@ func (s Service) FindAllDevicesByOwnerID(ownerID string) []ResponseDevice { result = append(result, ResponseDevice{ ID: doc.ID, IP: doc.IP, - Name: doc.Name, Platform: doc.Platform, OS: ResponseOS{ Name: doc.OSName, diff --git a/action_upsert.go b/action_upsert.go index f786305..aed7459 100644 --- a/action_upsert.go +++ b/action_upsert.go @@ -13,7 +13,6 @@ import ( type UpsertPayload struct { DeviceID string IP string - Name string UserAgent string AuthToken string FCMToken string @@ -41,12 +40,12 @@ func (s Service) Upsert(payload UpsertPayload) { // If not exist, create new stm, args, _ := s.Builder.Insert(TableDeviceMngt). Columns( - "id", "device_id", "ip", "name", "platform", + "id", "device_id", "ip", "platform", "os_name", "os_version", "browser_name", "browser_version", "auth_token", "fcm_token", "owner_id", "owner_type", "first_sign_in_at", "last_activity_at", ).Values( - mongodb.NewStringID(), payload.DeviceID, payload.IP, payload.Name, platform, + mongodb.NewStringID(), payload.DeviceID, payload.IP, platform, osInfo.Name, osInfo.Version, browserName, browserVersion, payload.AuthToken, payload.FCMToken, payload.OwnerID, payload.OwnerType, payload.FirstSignInAt, now(), @@ -62,7 +61,6 @@ func (s Service) Upsert(payload UpsertPayload) { // Else update stm, args, _ := s.Builder.Update(TableDeviceMngt). Set("ip", payload.IP). - Set("name", payload.Name). Set("platform", platform). Set("os_name", osInfo.Name). Set("os_version", osInfo.Version). diff --git a/find_by_device_id.go b/find_by_device_id.go index 9b62bf1..53843ed 100644 --- a/find_by_device_id.go +++ b/find_by_device_id.go @@ -8,7 +8,7 @@ import ( // findByDeviceID ... func (s Service) findByDeviceID(ctx context.Context, id string) (result Device) { - stm, args, _ := s.Builder.Select("*").From(DeviceMngtTableName).Where("device_id = ?", id).ToSql() + stm, args, _ := s.Builder.Select("*").From(TableDeviceMngt).Where("device_id = ?", id).ToSql() if err := s.DB.GetContext(ctx, &result, stm, args...); err != nil { logger.Error("devicemngt - findByDeviceID", logger.LogData{ diff --git a/model.go b/model.go index e5ae1b7..b02be14 100644 --- a/model.go +++ b/model.go @@ -7,7 +7,6 @@ type Device struct { ID string `db:"id"` DeviceID string `db:"device_id"` IP string `db:"ip"` - Name string `db:"name"` Platform string `db:"platform"` OSName string `db:"os_name"` OSVersion string `db:"os_version"` @@ -25,7 +24,6 @@ type Device struct { type ResponseDevice struct { ID string `json:"id"` IP string `json:"ip"` - Name string `json:"name"` Platform string `json:"platform"` OS ResponseOS `json:"os"` Browser ResponseBrowser `json:"browser"`