rphlmr ⚡
rphlmr ⚡
DTDrizzle Team
Created by Brokenwind on 7/3/2024 in #help
Exclude table from migration
Not sure the conf is used for migrations. If it is not the case, you could extract your auth schema related code in a separate file
3 replies
DTDrizzle Team
Created by Brokenwind on 7/3/2024 in #help
Exclude table from migration
You can exclude the authSchema in your drizzle config: https://orm.drizzle.team/kit-docs/config-reference#schemafilter
3 replies
DTDrizzle Team
Created by hk on 5/15/2024 in #help
Cannot read properties of undefined (reading 'compositePrimaryKeys')
Hey 👋 can you open an issue on GitHub for that? The team is hardly working on fixes
12 replies
DTDrizzle Team
Created by andreas_444 on 3/20/2024 in #help
Nested object in select query?
Look at jsonAggBuildObject
11 replies
DTDrizzle Team
Created by andreas_444 on 3/20/2024 in #help
Nested object in select query?
I have an example here: https://gist.github.com/rphlmr/de869cf24816d02068c3dd089b45ae82 Maybe not up to date. An other gist here with community contributions : https://gist.github.com/rphlmr/0d1722a794ed5a16da0fdf6652902b15
11 replies
DTDrizzle Team
Created by Screw on 5/18/2024 in #help
Making a key in a object with jsonb unique
Then, query api will help to grab everything together: https://orm.drizzle.team/docs/rqb
4 replies
DTDrizzle Team
Created by Screw on 5/18/2024 in #help
Making a key in a object with jsonb unique
Technically you can't. Your best option is to have an other table with wallet_address as primary key and userId as foreign key (1 user can have many wallets but a given wallet has only one owner).
4 replies
DTDrizzle Team
Created by pato on 5/17/2024 in #help
How to register triggers, events and functions
Personal practice: I use Supabase. On some projects, I need to enable RLS or add some policies, create some trigger functions, etc. I write and test them with their UI on a dev DB (I am not a SQL expert 😅) and then I copy the code into a Drizzle custom migration. drizzle-kit generate --custom
2 replies
DTDrizzle Team
Created by Ricardo Romero on 5/15/2024 in #help
Bigint in SQLite results in "TypeError: Do Not Know how to serialize a BigInt"
5 replies
DTDrizzle Team
Created by B33fb0n3 on 5/16/2024 in #help
Drizzle doesn't know how to serialize a bigint
Try without the n ? I guess it is only a JS thing right?
7 replies
DTDrizzle Team
Created by B33fb0n3 on 5/16/2024 in #help
Drizzle doesn't know how to serialize a bigint
Hello, Would you try this?
.default(sql`'262144000n'::bigint`)
.default(sql`'262144000n'::bigint`)
7 replies
DTDrizzle Team
Created by pato on 5/17/2024 in #help
findMany
Hello, it returns an empty array
3 replies
DTDrizzle Team
Created by TH on 5/17/2024 in #help
Issue with filtering on timestamp column
Hello, Date.now() returns a number and expirationDate is a Date. You could try new Date()
3 replies
DTDrizzle Team
Created by Sumiya_Sayeed34 on 5/17/2024 in #help
Drizzle postgres migration gives lots of type errors
let me introduce you drizzle-kit migrate since the last release :p https://orm.drizzle.team/kit-docs/commands#apply-migrations
3 replies
DTDrizzle Team
Created by Sumiya_Sayeed34 on 5/17/2024 in #help
Drizzle postgres migration gives lots of type errors
Hello, do you have "skipLibCheck": true, in your tsconfig compilerOptions ?
3 replies
DTDrizzle Team
Created by warflash on 2/9/2024 in #help
Custom Logic in Upsert/Insert on conflict
you can pass you own SQL with sql
3 replies
DTDrizzle Team
Created by warflash on 2/9/2024 in #help
Custom Logic in Upsert/Insert on conflict
Hello 👋 Not 100% sure but:
await db.insert(my_table)
.values({id, language, name,data,updated_at })
.onConflictDoUpdate({
target: [my_table.id, my_table.language],
set: { updated_at : sql`CASE
WHEN (${my_table.name} IS DISTINCT FROM EXCLUDED.name OR
${my_table.data} IS DISTINCT FROM EXCLUDED.data) THEN NOW() ELSE ${my_table.updated_at}
END` },
where: sql`${my_table.name} IS DISTINCT FROM EXCLUDED.name OR
${my_table.data} IS DISTINCT FROM EXCLUDED.data`,
});
await db.insert(my_table)
.values({id, language, name,data,updated_at })
.onConflictDoUpdate({
target: [my_table.id, my_table.language],
set: { updated_at : sql`CASE
WHEN (${my_table.name} IS DISTINCT FROM EXCLUDED.name OR
${my_table.data} IS DISTINCT FROM EXCLUDED.data) THEN NOW() ELSE ${my_table.updated_at}
END` },
where: sql`${my_table.name} IS DISTINCT FROM EXCLUDED.name OR
${my_table.data} IS DISTINCT FROM EXCLUDED.data`,
});
3 replies
DTDrizzle Team
Created by Gabriel Lucena on 2/11/2024 in #help
defaultFn not nullable
It is nullable for the schema because you have $defaultFn. So, id is not mandatory since a default value will be set.
2 replies
DTDrizzle Team
Created by Vithrax on 2/11/2024 in #help
createInsertSchema
👋 You need the type generated by Drizzle and not drizzle-zod:
export type NewRecipe = typeof recipes.$inferInsert;
export type NewRecipeAlt = InferInsertModel<typeof recipes>;
export type NewRecipe = typeof recipes.$inferInsert;
export type NewRecipeAlt = InferInsertModel<typeof recipes>;
https://orm.drizzle.team/docs/goodies#type-api
3 replies
DTDrizzle Team
Created by sevenwestonroads on 2/11/2024 in #help
Wrong drizzle generate with an array of text() in PSQL
for the 'why' I don't know 😬. I guess default works better for scalar types
3 replies