fix: use getRawDb() instead of drizzle $client for explore tab

$client doesn't exist in drizzle-orm 0.33, causing a TypeError and
500 on every /api/servers/explore request. Export the raw better-sqlite3
instance directly from db/index.ts instead.
This commit is contained in:
Jannis Braun
2026-03-05 00:51:55 +01:00
parent 39372980f7
commit bd7f65d33c
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
import type { FastifyInstance } from 'fastify';
import { eq, and, sql, inArray } from 'drizzle-orm';
import { getDb, schema } from '../db/index.js';
import { getDb, getRawDb, schema } from '../db/index.js';
import { authenticate } from '../utils/auth.js';
import { generateSnowflake } from '../utils/snowflake.js';
import { isMember, isServerOwner, hasPermission, computePermissions, PermissionBits, permissionsToString } from '../utils/permissions.js';
@@ -193,7 +193,7 @@ export async function exploreRoutes(app: FastifyInstance): Promise<void> {
// Build raw SQL query for explore — we need a LEFT JOIN for member count
// which is more efficient to do with raw SQL
const rawDb = (db as any).$client as import('better-sqlite3').Database;
const rawDb = getRawDb();
// Count ALL discoverable servers (including ones the user has joined) for context
const totalAllRow = rawDb.prepare(