fix(api): 修复 Drizzle 查询 where 子句的语法错误,采用 inArray 重构资产过滤条件
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user