Aryan
Aryan
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Aryan on 2/25/2024 in #questions
[Turborepo] How to exclude a folder?
thank you, i will give this a shot and drop an update here if i get it working ideally i have a few backend elysia servers running inside my pnpm turborepo workspace just like you mentioned
5 replies
DTDrizzle Team
Created by dBranded1 on 8/29/2023 in #help
Too many clients already (!?)
For create-t3-app users, the schema will be in another file - not in your main Drizzle client file by default. Just add this generic type to PostgresJsDatabase to fix this issue:
type PostgresJsDatabase<typeof schema>;
type PostgresJsDatabase<typeof schema>;
So the final file will look like:
// index.ts
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

import { env } from "~/env.js";
import * as schema from "./schema";

import { type PostgresJsDatabase } from "drizzle-orm/postgres-js";

// Fix for "sorry, too many clients already"
declare global {
// eslint-disable-next-line no-var -- only var works here
var db: PostgresJsDatabase<typeof schema> | undefined;
}

let db: PostgresJsDatabase<typeof schema>;

if (env.NODE_ENV === "production") {
db = drizzle(postgres(env.DATABASE_URL), { schema });
} else {
if (!global.db) global.db = drizzle(postgres(env.DATABASE_URL), { schema });

db = global.db;
}

export { db };
// index.ts
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

import { env } from "~/env.js";
import * as schema from "./schema";

import { type PostgresJsDatabase } from "drizzle-orm/postgres-js";

// Fix for "sorry, too many clients already"
declare global {
// eslint-disable-next-line no-var -- only var works here
var db: PostgresJsDatabase<typeof schema> | undefined;
}

let db: PostgresJsDatabase<typeof schema>;

if (env.NODE_ENV === "production") {
db = drizzle(postgres(env.DATABASE_URL), { schema });
} else {
if (!global.db) global.db = drizzle(postgres(env.DATABASE_URL), { schema });

db = global.db;
}

export { db };
11 replies
TTCTheo's Typesafe Cult
Created by Aryan on 4/19/2023 in #questions
How to let 2 types of users to login to my app - customers and businesses
Could you explain in a little more detail?
7 replies
TTCTheo's Typesafe Cult
Created by th3xaw3s0m3 on 4/18/2023 in #questions
How to create this image
@Th3xaw3s0m3 ik it’s solved but pretty sure this is https://ray.so/
11 replies