From 5ea9c8bdc40141ee6bda526d7ec050a2e7707fd0 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 20 Sep 2023 00:04:50 +0800 Subject: [PATCH] Backend change visitor country to country code alpha2 --- elysia/src/index.ts | 4 ++-- elysia/src/types.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elysia/src/index.ts b/elysia/src/index.ts index 66bbce1..7b84d46 100644 --- a/elysia/src/index.ts +++ b/elysia/src/index.ts @@ -65,7 +65,7 @@ app.get( const visitor_data = { shortener_id: shortener[0].id, - country: geolocation.data.location.country.name as string, + country_code: geolocation.data.location.country.alpha2 as string, } await db.insertInto('visitor').values(visitor_data).execute() @@ -92,7 +92,7 @@ app.get('/link/:shortenerCode', async ({ params: { shortenerCode } }) => { .selectFrom('visitor') .select([ 'visitor.created_at as visited_at', - 'visitor.country', + 'visitor.country_code', ]) .whereRef('visitor.shortener_id', '=', 'shortener.id') ).as('visitors'), diff --git a/elysia/src/types.ts b/elysia/src/types.ts index 85691cc..bd20939 100644 --- a/elysia/src/types.ts +++ b/elysia/src/types.ts @@ -25,7 +25,7 @@ export type ShortenerUpdate = Updateable export interface VisitorTable { id: Generated shortener_id: number - country: string + country_code: string created_at: ColumnType }