© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
35 replies
Screw

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
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Issues Using RLS with Supabase Through Drizzle
Drizzle TeamDTDrizzle Team / help
16mo ago
Drizzle & Supabase
Drizzle TeamDTDrizzle Team / help
10mo ago
Supabase & Drizzle
Drizzle TeamDTDrizzle Team / help
2y ago
Issues with drizzle-kit generate
Drizzle TeamDTDrizzle Team / help
2y ago