Skip to content

Commit

Permalink
Return location on country list
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Jun 27, 2024
1 parent 68096e1 commit 7ba11cf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/server/src/trpc/routes/countryList.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { db } from "@peated/server/db";
import type { SerializedPoint } from "@peated/server/db/columns";
import { countries } from "@peated/server/db/schema";
import { serialize } from "@peated/server/serializers";
import { CountrySerializer } from "@peated/server/serializers/country";
import { and, asc, ilike, type SQL } from "drizzle-orm";
import { and, asc, getTableColumns, ilike, sql, type SQL } from "drizzle-orm";
import { z } from "zod";
import { publicProcedure } from "..";

Expand All @@ -29,7 +30,10 @@ export default publicProcedure
}

const results = await db
.select()
.select({
...getTableColumns(countries),
location: sql<SerializedPoint>`ST_AsGeoJSON(${countries.location}) as location`,
})
.from(countries)
.where(where ? and(...where) : undefined)
.limit(limit + 1)
Expand Down

0 comments on commit 7ba11cf

Please sign in to comment.