TOSL
TOSL
Explore posts from servers
DTDrizzle Team
Created by quantumleaps on 2/21/2025 in #help
Error loading books: TypeError: Cannot read properties of undefined (reading 'referencedTable')
You don't need to use the Relations API if you don't want to. Simply create proper FKs and structuring your schema properly is enough to use the SQL-like select API. If you don't create the relations, you can't use the query API.
7 replies
DTDrizzle Team
Created by quantumleaps on 2/21/2025 in #help
Error loading books: TypeError: Cannot read properties of undefined (reading 'referencedTable')
7 replies
DTDrizzle Team
Created by bkyerv on 2/22/2025 in #help
Connection management with Drizzle
It is worth mentioning that if you want some control over the connections, it probably isn't too hard to do. Using postgres as a example, You might have something like this:
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from "postgres";

export const connection = postgres(process.env.DATABASE_URL, {
max: (process.env.DB_MIGRATING || env.DB_SEEDING) ? 1 : undefined,
});

export const db = drizzle(connection, {
schema,
logger: true,
});

export default db;
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from "postgres";

export const connection = postgres(process.env.DATABASE_URL, {
max: (process.env.DB_MIGRATING || env.DB_SEEDING) ? 1 : undefined,
});

export const db = drizzle(connection, {
schema,
logger: true,
});

export default db;
3 replies
DTDrizzle Team
Created by bkyerv on 2/22/2025 in #help
Connection management with Drizzle
This is unnecessary. The drizzle() function creates a database instance that you can throughout your application(s).
3 replies
DTDrizzle Team
Created by function on 2/5/2025 in #help
CTE / WITH + alias
Yea
11 replies
DTDrizzle Team
Created by function on 2/5/2025 in #help
CTE / WITH + alias
That's why you can't see it
11 replies
DTDrizzle Team
Created by function on 2/5/2025 in #help
CTE / WITH + alias
You have to enable shared playgrounds
11 replies
DTDrizzle Team
Created by looni on 2/20/2025 in #help
Issue with drizzle-kit and enums
Must export everything in schema you want Drizzle to know about
4 replies
DTDrizzle Team
Created by looni on 2/20/2025 in #help
Issue with drizzle-kit and enums
Must export the enum
4 replies
DTDrizzle Team
Created by Sparrow on 2/19/2025 in #help
how to model this query in drizzle
You need to alias the joins because they are the same table. Looks something like this
const winner = aliasedTable(user, "winner")
const runnerUp = aliasedTable(user, "runner_up"

etc

// then you join will look like this

.innerJoin(winner, ....)
.innerJoin(runnerUP, ...)
const winner = aliasedTable(user, "winner")
const runnerUp = aliasedTable(user, "runner_up"

etc

// then you join will look like this

.innerJoin(winner, ....)
.innerJoin(runnerUP, ...)
3 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
I believe it something they intend to improve in relation api v2
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
It's just not supported. The RQB using json aggregation to return the tables as arrays. It's just a limitation of how it was built.
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
you shouldn't need execute() though
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
Yeah this your best bet.
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
or just use db.select()
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
you can use a subquery
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
at least not directly
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
Query can't order by related fields
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
I see.
28 replies
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
Or have you tried that and it isn't the output you're looking for?
28 replies