fix(api): 修复 Drizzle 查询 where 子句的语法错误,采用 inArray 重构资产过滤条件

This commit is contained in:
2026-05-01 15:11:00 +08:00
parent b63691e1c8
commit 371ac24c0e
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server';
import { db } from '@/db';
import { assets, assetPricesHistory } from '@/db/schema';
import { eq } from 'drizzle-orm';
import { eq, inArray } from 'drizzle-orm';
import { ProxyAgent, setGlobalDispatcher } from 'undici';
export const dynamic = 'force-dynamic';
@@ -92,7 +92,7 @@ export async function GET(req: Request) {
const allAssets = await db
.select()
.from(assets)
.where(eq(assets.type, 'STOCK').or(eq(assets.type, 'CRYPTO')));
.where(inArray(assets.type, ['STOCK', 'CRYPTO']));
if (allAssets.length === 0) {
return NextResponse.json({