Screw
Screw
DTDrizzle Team
Created by Screw on 8/28/2024 in #help
pulling schema from database
No description
3 replies
DTDrizzle Team
Created by Screw on 5/18/2024 in #help
Making a key in a object with jsonb unique
type Wallets = {
wallet_address: string;
blockchain: string;
};

export const user = pgTable(
'user',
{
id: serial('id').primaryKey(),
wallets: jsonb('wallets').$type<Wallets[]>(),
);
type Wallets = {
wallet_address: string;
blockchain: string;
};

export const user = pgTable(
'user',
{
id: serial('id').primaryKey(),
wallets: jsonb('wallets').$type<Wallets[]>(),
);
how would i make wallet_address unique?
4 replies
DTDrizzle Team
Created by Screw on 1/6/2024 in #help
data is malformed on drizzle-kit V 0.20.10
No description
13 replies
DTDrizzle Team
Created by Screw on 10/29/2023 in #help
Using arrayContains with a jsonb postgres type
arrayContains(matches.teamA, [id])
arrayContains(matches.teamA, [id])
teamA is a jsonb type of string[] i want to see if the id exists inside whats the best way of doing this
4 replies
DTDrizzle Team
Created by Screw on 10/19/2023 in #help
where filter returning typescript error when nested within a with
No description
7 replies
DTDrizzle Team
Created by Screw on 9/22/2023 in #help
Transactions, PgBouncer/Supavisor, prepared statements
okay... i have spent way to long trying to figure out why when using transactions and a pooler on transaction mode it causes the connection to reset mid transaction statement causing a prepared statement 'name' does not exist which was very hard to debug. still don't fully understand why transaction won't work i've tried everything i could find setting params binary_parameters=yes (not even sure what this does, resetting database server (supabase). using a direct connection worked but wasn't something i could do forever. so my fix was.... just remove transactions from my endpoints (which sucks but it is what it is) if anyone else has this issue would love some help on how you worked around this or fixed???
2 replies
DTDrizzle Team
Created by Screw on 9/5/2023 in #help
is there a reason why my row isn't being delete with CURRENT_TIMESTAMP
const deleted_matches = await db
.delete(schema.matches)
.where(
and(
or(eq(schema.matches.status, 'PENDING'), eq(schema.matches.status, 'CANCELED')),
gt(schema.matches.expire_time, sql`CURRENT_TIMESTAMP`)
)
)
.returning();
const deleted_matches = await db
.delete(schema.matches)
.where(
and(
or(eq(schema.matches.status, 'PENDING'), eq(schema.matches.status, 'CANCELED')),
gt(schema.matches.expire_time, sql`CURRENT_TIMESTAMP`)
)
)
.returning();
expire_time is a sql timestamp with date and time
4 replies
DTDrizzle Team
Created by Screw on 8/22/2023 in #help
0.28.3 types issue
is there a new way to handle typings in 0.28.3 i get type errors on my table builders and on 0.28.1 i do not
3 replies
DTDrizzle Team
Created by Screw on 8/18/2023 in #help
Issues with supabase inserts with drizzle
const team = await db.transaction(async (tx) => {
const [team] = await tx.insert(teams).values(teamObj).returning();

await tx.insert(team_stats).values({
team_id: team.id,
total_losses: 0,
total_wins: 0,
xp: 0,
total_money_earned: 0,
total_money_lost: 0
});

await tx.insert(user_teams).values({
team_id: team.id,
user_id: Number(locals.user.id)
});

return team;
});

//make sure team is in db
const [test] = await db.query.teams.findMany({
where: (teams, { eq }) => eq(teams.id, team.id)
});
const team = await db.transaction(async (tx) => {
const [team] = await tx.insert(teams).values(teamObj).returning();

await tx.insert(team_stats).values({
team_id: team.id,
total_losses: 0,
total_wins: 0,
xp: 0,
total_money_earned: 0,
total_money_lost: 0
});

await tx.insert(user_teams).values({
team_id: team.id,
user_id: Number(locals.user.id)
});

return team;
});

//make sure team is in db
const [test] = await db.query.teams.findMany({
where: (teams, { eq }) => eq(teams.id, team.id)
});
the transaction returns the team object with id from supabase db but when querying it to make sure it exists the team is not found. not sure whats going on exactly would love some clarification on is i'm just missing something
36 replies