Skip to content

Commit

Permalink
Fix countries query on entity serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Jun 27, 2024
1 parent 7ba11cf commit f49eba2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/server/src/serializers/entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inArray } from "drizzle-orm";
import { getTableColumns, inArray, sql } from "drizzle-orm";
import { type z } from "zod";
import { serialize, serializer } from ".";
import { db } from "../db";
Expand All @@ -13,7 +13,10 @@ export const EntitySerializer = serializer({
const countryIds = itemList.map((i) => i.countryId).filter(notEmpty);
const countryList = countryIds.length
? await db
.select()
.select({
...getTableColumns(countries),
location: sql<SerializedPoint>`ST_AsGeoJSON(${countries.location}) as location`,
})
.from(countries)
.where(inArray(countries.id, countryIds))
: [];
Expand Down

0 comments on commit f49eba2

Please sign in to comment.