Infinite loading of queries

Hey! I am trying to use Drizzle with Neon Postgres. I made the migrations, ran them and the tables are there. Now whenever I select or insert data, the request just hangs and does not proceed. I am using serverless neon package since I will be running in Vercel Edge Functions. Here is the code:
import {drizzle} from "drizzle-orm/neon-serverless";
import {Pool} from '@neondatabase/serverless';
import {Orders} from "@/app/db/schema";
import {eq} from "drizzle-orm";

export interface Order {
instagram_post_id: string
}

const client = new Pool({
connectionString: process.env.DATABASE_CONNECTION_STRING,
ssl: true,
idleTimeoutMillis: 20000,
})
const db = drizzle(client)

export const getOrder = async (id: string) => {
return db.select().from(Orders).where(eq(Orders.instagram_post_id, id));
}
export const addOrder = async (order: Order) => {
try {
const orderReq = await db.insert(Orders).values({
instagram_post_id: order.instagram_post_id,
}).returning()
console.log({orderReq})
} catch (e) {
console.log({e})
}
return order
}
import {drizzle} from "drizzle-orm/neon-serverless";
import {Pool} from '@neondatabase/serverless';
import {Orders} from "@/app/db/schema";
import {eq} from "drizzle-orm";

export interface Order {
instagram_post_id: string
}

const client = new Pool({
connectionString: process.env.DATABASE_CONNECTION_STRING,
ssl: true,
idleTimeoutMillis: 20000,
})
const db = drizzle(client)

export const getOrder = async (id: string) => {
return db.select().from(Orders).where(eq(Orders.instagram_post_id, id));
}
export const addOrder = async (order: Order) => {
try {
const orderReq = await db.insert(Orders).values({
instagram_post_id: order.instagram_post_id,
}).returning()
console.log({orderReq})
} catch (e) {
console.log({e})
}
return order
}
route.ts
import {NextResponse} from 'next/server'
import {addOrder, getOrder} from "@/lib/drizzle";

export async function POST(req: Request) {
const data = await req.json()
console.log({data})
const addRequest = await addOrder(data)
console.log({addRequest})
return NextResponse.json({addRequest})
}

export async function GET(req: Request) {
console.log("Request Made")
const {searchParams} = new URL(req.url)
const id = searchParams.get('id') ?? ""
const getReq = await getOrder(id)
console.log({getReq})
return NextResponse.json({getReq})
}
import {NextResponse} from 'next/server'
import {addOrder, getOrder} from "@/lib/drizzle";

export async function POST(req: Request) {
const data = await req.json()
console.log({data})
const addRequest = await addOrder(data)
console.log({addRequest})
return NextResponse.json({addRequest})
}

export async function GET(req: Request) {
console.log("Request Made")
const {searchParams} = new URL(req.url)
const id = searchParams.get('id') ?? ""
const getReq = await getOrder(id)
console.log({getReq})
return NextResponse.json({getReq})
}
4 Replies
alexblokh
alexblokh2y ago
try select 1; without drizzle, just using client
ultrakiller
ultrakillerOP2y ago
const {rows} = await client.query("SELECT * FROM orders")
console.log({rows})
const {rows} = await client.query("SELECT * FROM orders")
console.log({rows})
I do get the results back with this
Asseater Peter
Asseater Peter17mo ago
Try using db.query.Orders.findOne ? @.ultrakiller If you want I have some time to kill and I can join a call or something, would probably be faster following up on this. @.ultrakiller any luck? btw, don't forget to mark the thread as done for my OCD's sake @.ultrakiller
ultrakiller
ultrakillerOP17mo ago
hey! i'm sorry for being unresponsive, I had an exam to take. As far as the issue is concerned, I moved to a supabase instance and it worked with little to no config change.
Want results from more Discord servers?
Add your server