Pradip Chaudhary
DTDrizzle Team
•Created by yasserconnect on 7/5/2024 in #help
use limit or undefined
Thanks @eXecuteye and @Raphaël M (@rphlmr) ⚡ for this, I will keep this in mind now
12 replies
DTDrizzle Team
•Created by yasserconnect on 7/5/2024 in #help
use limit or undefined
Which one exactly @eXecuteye ?
12 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/8/2024 in #help
drizzle-studio showing duplicate relations
But we need to define that relation for proper type safety right?
5 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/8/2024 in #help
drizzle-studio showing duplicate relations
5 replies
DTDrizzle Team
•Created by Ani on 7/7/2024 in #help
error: cannot use column reference in DEFAULT expression
Have you pushed the schema to db earlier with serial data type?
If yes, then it may be the reason that it's not allowing to change it now
7 replies
DTDrizzle Team
•Created by Boby on 7/7/2024 in #help
Property 'userTable' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is.. ">
My pleasure 😊
5 replies
DTDrizzle Team
•Created by Boby on 7/7/2024 in #help
Property 'userTable' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is.. ">
Hey @Boby
It seems to me that you've not passed your schemas to the function call while create the db instance like following
import * as schema from "./schema";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
const queryClient = postgres(process.env.DATABASE_URL);
export const db = drizzle(queryClient, { schema });
5 replies
DTDrizzle Team
•Created by Ani on 7/7/2024 in #help
error: cannot use column reference in DEFAULT expression
Hey @Ani
the problem is that you are using serial instead of integer.
Serial is an auto-incrementing data type which is mainly useful for pk as id because it increases by 1 every time you add a record in the table.
For your use case as per I can understand, you need an integer for the length which can also have a default value of 0.
7 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/6/2024 in #help
Wrong migration SQL generating
@Raphaël M (@rphlmr) ⚡ thanks
I missed that. Silly copilot 🥺
I should have checked it properly before asking
9 replies
DTDrizzle Team
•Created by yasserconnect on 7/5/2024 in #help
use limit or undefined
Yess, that's what I did 😊
12 replies
DTDrizzle Team
•Created by yasserconnect on 7/5/2024 in #help
use limit or undefined
Hey @yasserconnect ,
You need to parse the limit value as int because that's what the limit function expects.
const limit = searchParams?.get("limit");
const limitValue = limit ? parseInt(limit, 10) : null;
const result = await db.select().from(shipment).orderBy(desc(shipment.createdAt));
if (limitValue) {
result.limit(limitValue);
}
You can also set limitValue to 0 if limit is not there as drizzle treats 0 as having no limit only.
const limit = searchParams?.get("limit");
const limitValue = limit ? parseInt(limit, 10) : 0;
const result = await db.select().from(shipment).orderBy(desc(shipment.createdAt)).limit(limitValue);
12 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/6/2024 in #help
Wrong migration SQL generating
drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
schema: "./src/db/schema.ts",
out: "./src/db/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
verbose: true,
strict: true,
});
9 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/6/2024 in #help
Wrong migration SQL generating
9 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/6/2024 in #help
Wrong migration SQL generating
generated sql file
9 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/6/2024 in #help
Wrong migration SQL generating
9 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 7/6/2024 in #help
Wrong migration SQL generating
schema.ts file
9 replies
DTDrizzle Team
•Created by Pradip Chaudhary on 5/1/2024 in #help
Multiple Where Clauses
Thank you so much Sillvva. I think this will definitely solve my long-standing issue.
3 replies