1

using mariadb npmjs version: 2.1.2

import mariadb from "mariadb";
const pool = mariadb.createPool({host: process.env.DBHOST, user: process.env.DBUSER, password: process.env.DBPASS, port: process.env.DBPORT, connectionLimit: process.env.DBCONNLIMIT, rowsAsArray: true });

pool.getConnection((err: any, conn: any) => {
        if (err) {
          console.log("not connected due to error: " + err);
        } else {
          console.log("connected ! connection id is " + conn.threadId);
          conn.end(); //release to pool
        }
      });

the getConnection portion is giving me typescript errors Expected 0 arguments, but got 1.ts(2554)

Even though mariadb package suggest it has types defined for typescript, however, I noticed their types are not correct based on the example in documentation.

my usage of pool.getConnection is coming straight from documentation example. This is the line in the types:

export interface Pool {
  /**
   * Retrieve a connection from pool.
   * Create a new one, if limit is not reached.
   * wait until acquireTimeout.
   */
  getConnection(): Promise<PoolConnection>;

At MariaDB/mariadb-connector-nodejs

Is there a way I could override this or should I create an issue in the github repo? I am not sure whether I'm looking at it correctly. Thanks.

1 Answer 1

1

MariaDB node.js connector implement "promise" implementation by default

see https://github.com/mariadb-corporation/mariadb-connector-nodejs#documentation

See promise documentation for detailed API.

Callback documentation describe the callback wrapper for compatibility with existing drivers.

I don't find the exact documentation part you refer to, but it seems to refer to callback implementation. Typescript descriptor use promise implementation only.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.