ultrakiller
ultrakiller
Explore posts from servers
DTDrizzle Team
Created by ultrakiller on 8/12/2023 in #help
How am I supposed to put unique constraints on columns
13 replies
DTDrizzle Team
Created by ultrakiller on 8/9/2023 in #help
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})
}
8 replies
AAAndronix App
Created by ultrakiller on 7/21/2023 in #support-forum
Hey!
This is a hello world post for this forum. We hope that you can find answers in a better way here. Remember to search before you post tho. Have a great time.
28 replies
RRailway
Created by ultrakiller on 7/18/2023 in #✋|help
How to temporarily pause services
Hey! I couldn't find a resource that lets me pause some deployed node.js services so that I do not incur charges while they are not in use. Help will be appreciated.
14 replies