Skip to content

Commit f3cc070

Browse files
author
Michael Kornelakis
committed
create ArgumentsArray type and remove FieldInfo export
1 parent f4fea35 commit f3cc070

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

examples/connection/typescript/src/returnArgumentsArray.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import mysql from '../../../../index';
2-
import type { FieldInfo, Query } from '../../../../index';
1+
import mysql, { ArgumentsArray } from '../../../../index';
32
import { Employee } from './employee';
43

54
function run() {
@@ -13,7 +12,7 @@ function run() {
1312
}).then((conn) => {
1413
connection = conn;
1514

16-
return connection.query<[data: Employee[], fields: FieldInfo[], query: Query<Employee>]>('select * from employees limit 0, 10');
15+
return connection.query<ArgumentsArray<Employee>>('select * from employees limit 0, 10');
1716
}).then(([data, fields, query]) => {
1817
console.log(`The SQL for the query was: ${query.sql}\n`);
1918

@@ -40,7 +39,7 @@ async function runAwait() {
4039
returnArgumentsArray: true
4140
});
4241

43-
const [data, fields, query] = await connection.query<[data: Employee[], fields: mysql.FieldInfo[], query: Query<Employee>]>('select * from employees limit 0, 10');
42+
const [data, fields, query] = await connection.query<ArgumentsArray<Employee>>('select * from employees limit 0, 10');
4443

4544
console.log(`The SQL for the query was: ${query.sql}\n`);
4645

index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import * as mysql from 'mysql';
2-
import * as Bluebird from 'bluebird';
3-
4-
export type { FieldInfo } from 'mysql';
2+
import Bluebird from 'bluebird';
53

64
export function createConnection(connectionUri: string | ConnectionConfig): Bluebird<Connection>;
75

@@ -12,6 +10,8 @@ export function createPoolCluster(config: mysql.PoolClusterConfig): Bluebird<Poo
1210
export { Types, escape, escapeId, format, raw, ConnectionOptions, PoolClusterConfig, MysqlError } from 'mysql';
1311

1412
export type mysqlModule = typeof mysql;
13+
14+
export type ArgumentsArray<T> = [data: T[], fields: mysql.FieldInfo[], query: Query<T>];
1515
export interface ConnectionConfig extends mysql.ConnectionConfig {
1616
mysqlWrapper?: (mysql: mysqlModule, callback?: (err: Error | null, success?: mysqlModule) => void) => mysqlModule | Promise<mysqlModule> | void;
1717
returnArgumentsArray?: boolean;

0 commit comments

Comments
 (0)