Dax Raad 5 месяцев назад
Родитель
Сommit
3fa02623c3
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      cloud/core/src/drizzle/index.ts

+ 3 - 1
cloud/core/src/drizzle/index.ts

@@ -3,7 +3,7 @@ import { Resource } from "sst"
 export * from "drizzle-orm"
 import postgres from "postgres"
 
-const createClient = () => {
+const init = () => {
   const client = postgres({
     idle_timeout: 30000,
     connect_timeout: 30000,
@@ -20,6 +20,8 @@ const createClient = () => {
   return drizzle(client, {})
 }
 
+const createClient = "NODE_ENV" in process.env ? init : memo(init)
+
 import { PgTransaction, type PgTransactionConfig } from "drizzle-orm/pg-core"
 import type { ExtractTablesWithRelations } from "drizzle-orm"
 import type { PostgresJsQueryResultHKT } from "drizzle-orm/postgres-js"