SKUZZIE
SKUZZIE
DTDrizzle Team
Created by SKUZZIE on 12/11/2024 in #help
Select without from?
Looks like we're still waiting for this :Sadge: https://github.com/drizzle-team/drizzle-orm/pull/1405
2 replies
DTDrizzle Team
Created by Bruno on 12/3/2024 in #help
Next.js, Drizzle and Supabase DB with transactions?
Hope this helps understand the difference a bit
14 replies
DTDrizzle Team
Created by Bruno on 12/3/2024 in #help
Next.js, Drizzle and Supabase DB with transactions?
Connection pooling is one of the harder concepts to deal with when learning SQL initially. Basically, SQL servers typically don't communicate over HTTP but with sockets (like websockets). You can think of HTTP as like sending a text message versus sockets are making a phone call. Those sockets are resource expensive and take a while to start and stop, but you can keep them around to do more than just one thing at a time and give you safety for things like transactions. Databases have a limit to how many sockets or "phone calls" they can have open at a given time. So, you use a pooler to manage those open socket connections for you. When you're running in a serverless environment your code boots up and exits quickly and often, so poolers keeps open sockets around for you to quickly reuse. You'll need to choose the transaction mode based on how you are running your code (serverless vs serverfull) because it affects how those connections/sockets will be pooled.
14 replies
DTDrizzle Team
Created by gwilliamnn on 11/11/2024 in #help
With Query mode, is possible filter by a related table?
Not currently, you can follow the discussion around this here: https://github.com/drizzle-team/drizzle-orm/discussions/1152 Basically, wait for the V2 release or just stick to manually building the queries with aggregations.
3 replies
DTDrizzle Team
Created by SKUZZIE on 11/6/2024 in #help
Do prepared statement names matter?
Interesting. If Drizzle prepared statements are separate I don't see the need for the name other than for identifying it in logging. I'm curious if someone who knows more about it can chime in.
7 replies
DTDrizzle Team
Created by SKUZZIE on 11/6/2024 in #help
Do prepared statement names matter?
I guess the Postgres docs clarifies a bit:
An arbitrary name given to this particular prepared statement. It must be unique within a single session and is subsequently used to execute or deallocate a previously prepared statement.
But the wording on the Drizzle docs makes it sound like the statement is prepared within Drizzle, not the database:
With prepared statements you do SQL concatenation once on the Drizzle ORM side and then database driver is able to reuse precompiled binary SQL instead of parsing query all the time.
7 replies
DTDrizzle Team
Created by SKUZZIE on 12/14/2023 in #help
Upsert with multi-column unique index?
Oh my gosh I think I figured it out. It's because I had ad_id set as the primary key, but I really want both ad_id and date to be the primary key. The upsert was working, it was erroring when I was creating another record with the same primary key (as it's supposed to). facepalm Thank you for your help @solo @Angelelz !!!
28 replies
DTDrizzle Team
Created by SKUZZIE on 12/14/2023 in #help
Upsert with multi-column unique index?
I was going to try the last two ideas you had, but doing either throws type errors. Are you sure doing that is supported in Drizzle?
28 replies
DTDrizzle Team
Created by SKUZZIE on 12/14/2023 in #help
Upsert with multi-column unique index?
This is the error again:
NeonDbError: db error: ERROR: duplicate key value violates unique constraint "daily_stats_pkey"
DETAIL: Key (ad_id)=(QP1VlfoJo4QQ_XTL) already exists.
NeonDbError: db error: ERROR: duplicate key value violates unique constraint "daily_stats_pkey"
DETAIL: Key (ad_id)=(QP1VlfoJo4QQ_XTL) already exists.
28 replies
DTDrizzle Team
Created by SKUZZIE on 12/14/2023 in #help
Upsert with multi-column unique index?
@solo Unfortunately I'm still getting the same error. This is what I changed my code to:
const date = dayjs().format("YYYY-MM-DD");
...
await db
.insert(dailyStats)
.values({
ad_id: dbAd.id,
date: date,
...dailyStatsInsert,
})
.onConflictDoUpdate({
target: [dailyStats.ad_id, dailyStats.date],
set: dailyStatsInsert,
});
const date = dayjs().format("YYYY-MM-DD");
...
await db
.insert(dailyStats)
.values({
ad_id: dbAd.id,
date: date,
...dailyStatsInsert,
})
.onConflictDoUpdate({
target: [dailyStats.ad_id, dailyStats.date],
set: dailyStatsInsert,
});
28 replies
DTDrizzle Team
Created by SKUZZIE on 12/14/2023 in #help
Upsert with multi-column unique index?
Yeah here's the full error:
NeonDbError: db error: ERROR: duplicate key value violates unique constraint "daily_stats_pkey"
DETAIL: Key (ad_id)=(MGIkhCKqgCE0Ga1J) already exists.
NeonDbError: db error: ERROR: duplicate key value violates unique constraint "daily_stats_pkey"
DETAIL: Key (ad_id)=(MGIkhCKqgCE0Ga1J) already exists.
Let me test without the ISOString, thank you!!
28 replies