Your IP : 216.73.217.13


Current Path : /var/www/recommendations/www/node_modules/mysql2/typings/mysql/lib/
Upload File :
Current File : /var/www/recommendations/www/node_modules/mysql2/typings/mysql/lib/Pool.d.ts

import { EventEmitter } from 'events';
import { Query, QueryError, QueryOptions } from './protocol/sequences/Query.js';
import {
  OkPacket,
  RowDataPacket,
  FieldPacket,
  ResultSetHeader,
} from './protocol/packets/index.js';
import { ConnectionOptions } from './Connection.js';
import { PoolConnection } from './PoolConnection.js';
import { Pool as PromisePool } from '../../../promise.js';

export interface PoolOptions extends ConnectionOptions {
  /**
   * The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout,
   * because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds)
   */
  acquireTimeout?: number;

  /**
   * Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue
   * the connection request and call it when one becomes available. If false, the pool will immediately call back with an error.
   * (Default: true)
   */
  waitForConnections?: boolean;

  /**
   * The maximum number of connections to create at once. (Default: 10)
   */
  connectionLimit?: number;

  /**
   * The maximum number of idle connections. (Default: same as `connectionLimit`)
   */
  maxIdle?: number;

  /**
   * The idle connections timeout, in milliseconds. (Default: 60000)
   */
  idleTimeout?: number;

  /**
   * The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there
   * is no limit to the number of queued connection requests. (Default: 0)
   */
  queueLimit?: number;

  /**
   * Enable keep-alive on the socket. (Default: true)
   */
  enableKeepAlive?: boolean;

  /**
   * If keep-alive is enabled users can supply an initial delay. (Default: 0)
   */
  keepAliveInitialDelay?: number;
}

declare class Pool extends EventEmitter {
  config: PoolOptions;

  getConnection(
    callback: (
      err: NodeJS.ErrnoException | null,
      connection: PoolConnection
    ) => any
  ): void;

  releaseConnection(connection: PoolConnection): void;

  query<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    sql: string,
    callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
  ): Query;
  query<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    sql: string,
    values: any | any[] | { [param: string]: any },
    callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
  ): Query;
  query<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    options: QueryOptions,
    callback?: (
      err: QueryError | null,
      result: T,
      fields?: FieldPacket[]
    ) => any
  ): Query;
  query<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    options: QueryOptions,
    values: any | any[] | { [param: string]: any },
    callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
  ): Query;

  execute<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    sql: string,
    callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
  ): Query;
  execute<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    sql: string,
    values: any | any[] | { [param: string]: any },
    callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
  ): Query;
  execute<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    options: QueryOptions,
    callback?: (
      err: QueryError | null,
      result: T,
      fields?: FieldPacket[]
    ) => any
  ): Query;
  execute<
    T extends
      | RowDataPacket[][]
      | RowDataPacket[]
      | OkPacket
      | OkPacket[]
      | ResultSetHeader
  >(
    options: QueryOptions,
    values: any | any[] | { [param: string]: any },
    callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
  ): Query;

  end(
    callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any
  ): void;

  on(event: string, listener: (args: any[]) => void): this;
  on(event: 'connection', listener: (connection: PoolConnection) => any): this;

  promise(promiseImpl?: PromiseConstructor): PromisePool;
}

export { Pool };