removed unused type

This commit is contained in:
Ben Borla 2024-12-09 15:26:13 +08:00
commit bd0a6a9ef2

View file

@ -21,6 +21,14 @@ interface ColumnRow {
data_type: string; data_type: string;
} }
interface QueryResult {
content: Array<{
type: string;
text: string;
}>;
isError: boolean;
}
const config = { const config = {
server: { server: {
name: "example-servers/mysql", name: "example-servers/mysql",
@ -39,11 +47,11 @@ const config = {
}, },
}; };
const mysqlQuery = ( const mysqlQuery = <T>(
connection: PoolConnection, connection: PoolConnection,
sql: string, sql: string,
params: any[] = [], params: any[] = [],
): Promise<any> => { ): Promise<T> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
connection.query(sql, params, (error: MySQLErrorType, results: any) => { connection.query(sql, params, (error: MySQLErrorType, results: any) => {
if (error) reject(error); if (error) reject(error);
@ -91,17 +99,17 @@ const server = new Server(config.server, {
}, },
}); });
async function executeQuery(sql: string, params: any[] = []): Promise<any> { async function executeQuery<T>(sql: string, params: any[] = []): Promise<T> {
const connection = await mysqlGetConnection(pool); const connection = await mysqlGetConnection(pool);
try { try {
const results = await mysqlQuery(connection, sql, params); const results = await mysqlQuery<T>(connection, sql, params);
return results; return results;
} finally { } finally {
connection.release(); connection.release();
} }
} }
async function executeReadOnlyQuery(sql: string): Promise<any> { async function executeReadOnlyQuery<T>(sql: string): Promise<T> {
const connection = await mysqlGetConnection(pool); const connection = await mysqlGetConnection(pool);
try { try {
@ -120,7 +128,7 @@ async function executeReadOnlyQuery(sql: string): Promise<any> {
// Reset to read-write mode // Reset to read-write mode
await mysqlQuery(connection, "SET SESSION TRANSACTION READ WRITE"); await mysqlQuery(connection, "SET SESSION TRANSACTION READ WRITE");
return { return <T>{
content: [ content: [
{ {
type: "text", type: "text",