AggregateError on accessing my db with drizzle-orm and supabase

/src/api/db.ts
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';

const connectionString = process.env.DATABASE_URL;

const client = postgres(connectionString!, { prepare: false });
export const db = drizzle(client);
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';

const connectionString = process.env.DATABASE_URL;

const client = postgres(connectionString!, { prepare: false });
export const db = drizzle(client);
/src/api/index.ts
import { cache } from "@solidjs/router";
import { getSeasons as gS } from "./server";

export const getSeasons = cache(gS, "seasons");
import { cache } from "@solidjs/router";
import { getSeasons as gS } from "./server";

export const getSeasons = cache(gS, "seasons");
/src/api/server.ts
"use server";

import { season } from "../../drizzle/schema";
import { db } from "./db";

export const getSeasons = async () => {
return await db.select().from(season);
};
"use server";

import { season } from "../../drizzle/schema";
import { db } from "./db";

export const getSeasons = async () => {
return await db.select().from(season);
};
/src/routes/index.tsx
import { createAsync, type RouteDefinition } from '@solidjs/router';
import { For } from 'solid-js';
import { getSeasons } from '~/api/server';

export const route = {} satisfies RouteDefinition;

export default function Home() {
const seasons = createAsync(async () => getSeasons(), { deferStream: true });

return (
<main class='w-full p-4 space-y-2'>
<h3 class='font-bold text-xl'>Hello world!</h3>
<For each={seasons()}>{(season) => <p>{season.title}</p>}</For>
</main>
);
}
import { createAsync, type RouteDefinition } from '@solidjs/router';
import { For } from 'solid-js';
import { getSeasons } from '~/api/server';

export const route = {} satisfies RouteDefinition;

export default function Home() {
const seasons = createAsync(async () => getSeasons(), { deferStream: true });

return (
<main class='w-full p-4 space-y-2'>
<h3 class='font-bold text-xl'>Hello world!</h3>
<For each={seasons()}>{(season) => <p>{season.title}</p>}</For>
</main>
);
}
I have a supabase db with a table called seasons. I want to access all seasons (for now inside index.tsx, but later also in the app.tsx) and display them. But this doesn't work and only display an AggregateError :/
3 Replies
𝔐𝔞𝔱𝔱𝔦𝔫
Here is the error message:
AggregateError
at internalConnectMultiple (node:net:1114:18)
at afterConnectMultiple (node:net:1667:5)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'ECONNREFUSED',
[errors]: [
Error: connect ECONNREFUSED ::1:5432
at createConnectionError (node:net:1634:14)
at afterConnectMultiple (node:net:1664:40)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 5432
},
Error: connect ECONNREFUSED 127.0.0.1:5432
at createConnectionError (node:net:1634:14)
at afterConnectMultiple (node:net:1664:40)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}
]
}
AggregateError
at internalConnectMultiple (node:net:1114:18)
at afterConnectMultiple (node:net:1667:5)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'ECONNREFUSED',
[errors]: [
Error: connect ECONNREFUSED ::1:5432
at createConnectionError (node:net:1634:14)
at afterConnectMultiple (node:net:1664:40)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 5432
},
Error: connect ECONNREFUSED 127.0.0.1:5432
at createConnectionError (node:net:1634:14)
at afterConnectMultiple (node:net:1664:40)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}
]
}
Is anyone able to help me?
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
𝔐𝔞𝔱𝔱𝔦𝔫
You are right. I had a problem with my env, but fixed it now. Thanks :D
Want results from more Discord servers?
Add your server