perf: 倒序

This commit is contained in:
archer
2023-04-18 23:51:30 +08:00
parent 9e951fbc15
commit 629a147741
2 changed files with 2 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
const searchRes = await pg.query<PgModelDataItemType>(`SELECT id, q, a, status
FROM modelData
WHERE user_id='${userId}' AND model_id='${modelId}'
ORDER BY id DESC
LIMIT ${pageSize} OFFSET ${pageSize * (pageNum - 1)}
`);

View File

@@ -16,9 +16,6 @@ export const connectPg = async () => {
connectionTimeoutMillis: 2000
});
global.pgClient.on('connect', () => {
console.log('pg connected');
});
global.pgClient.on('error', (err) => {
console.log(err);
global.pgClient = null;
@@ -26,6 +23,7 @@ export const connectPg = async () => {
try {
await global.pgClient.connect();
console.log('pg connected');
return global.pgClient;
} catch (error) {
global.pgClient = null;