farhan
DTDrizzle Team
•Created by farhan on 11/4/2024 in #help
Deprecated function table.d.ts(26, 8): The declaration was marked as deprecated here.
4 replies
DTDrizzle Team
•Created by farhan on 6/17/2024 in #help
PostgresError: sorry, too many clients already
import { drizzle } from 'drizzle-orm/postgres-js';
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';
import * as schema from './schema';
// for migrations
const migrationClient = postgres("postgres://root@localhost:5432/cafekampung", { max: 1 });
migrate(drizzle(migrationClient), {
migrationsFolder: "drizzle",
migrationsTable: "drizzle_migrations",
migrationsSchema: "public",
});
// for query purposes
const queryClient = postgres("postgres://root@localhost:5432/cafekampung");
export const db = drizzle(queryClient, { schema });
import { drizzle } from 'drizzle-orm/postgres-js';
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';
import * as schema from './schema';
// for migrations
const migrationClient = postgres("postgres://root@localhost:5432/cafekampung", { max: 1 });
migrate(drizzle(migrationClient), {
migrationsFolder: "drizzle",
migrationsTable: "drizzle_migrations",
migrationsSchema: "public",
});
// for query purposes
const queryClient = postgres("postgres://root@localhost:5432/cafekampung");
export const db = drizzle(queryClient, { schema });
import { db } from "@/db";
import { restaurants } from "@/db/schema";
import { eq } from "drizzle-orm";
export function getAllMenu() {
return db.query.restaurants.findFirst({
where: eq(restaurants.id, 2),
with: {
menuItems: true
}
})
}
import { db } from "@/db";
import { restaurants } from "@/db/schema";
import { eq } from "drizzle-orm";
export function getAllMenu() {
return db.query.restaurants.findFirst({
where: eq(restaurants.id, 2),
with: {
menuItems: true
}
})
}
⨯ PostgresError: sorry, too many clients already
at Socket.emit (node:events:517:28)
digest: "3057589683"
⨯ PostgresError: sorry, too many clients already
at Socket.emit (node:events:517:28)
digest: "3057589683"
5 replies
DTDrizzle Team
•Created by farhan on 4/19/2024 in #help
DRIZZLE + NEXTJS App router + Supabase Error postgres js timeout
this is my code
This is the error
"use server";
import { db } from "@/db";
import { users } from "@/db/schema";
import { auth } from "@clerk/nextjs"
import { eq } from "drizzle-orm";
export async function checkUser() {
try {
const { sessionClaims } = auth()
const user = await db.select().from(users).where(eq(users.email, sessionClaims?.email as string))
console.log(user)
if (user === undefined) {
const res = await db.insert(users).values({
email: sessionClaims?.email as string,
nama: `${sessionClaims?.first_name} ${sessionClaims?.last_name}`,
nombor_telefon: '',
negeri: ''
}).returning()
console.log("user takde")
return res
}
} catch (err) {
console.log("error")
console.log(err)
}
}
"use server";
import { db } from "@/db";
import { users } from "@/db/schema";
import { auth } from "@clerk/nextjs"
import { eq } from "drizzle-orm";
export async function checkUser() {
try {
const { sessionClaims } = auth()
const user = await db.select().from(users).where(eq(users.email, sessionClaims?.email as string))
console.log(user)
if (user === undefined) {
const res = await db.insert(users).values({
email: sessionClaims?.email as string,
nama: `${sessionClaims?.first_name} ${sessionClaims?.last_name}`,
nombor_telefon: '',
negeri: ''
}).returning()
console.log("user takde")
return res
}
} catch (err) {
console.log("error")
console.log(err)
}
}
6 replies