All pages
Powered by GitBook
1 of 1

Loading...

Connector/Node.js 3.0.0-beta Release Notes

Download | Release Notes | Changelog |

Release date: 30 Jun 2021

MariaDB Connector/Node.js 3.0.0 is a Beta release.

Do not use beta releases in production!

For an overview of MariaDB Connector/Node.js see the page

Notable Changes

Prepared statement implementation

Driver now permits using prepared statement. This methods are compatible with mysql2 with some differences:

  • permit streaming parameters

  • execute use by default a prepared cache that hasn't infinite length (option ‘prepareCacheLength’ with default to 256)

  • Implement new feature, skipping metadata when possible for better performance

New Connection methods:

  • : Prepares a query.

  • : Prepare and Executes a query.

Example:

Or directly :

If reusing query multiple time, this permits to perform better, specifically using . Performance comparison with mysql2 driver show up to 20% performance gain. More info will follow before GA release.

Exact Number implementation

Default behaviour for decoding / datatype for 2.x version and mysql/mysql2 drivers return a javascript object. BIGINT / DECIMAL values might not be in the safe range, resulting in approximate results.

Since 3.x version, driver has reliable default, returning:

  • DECIMAL => javascript String

  • BIGINT => javascript object

For compatibility with the previous versions or mysql/mysql driver, 3 options have been added to return BIGINT/DECIMAL as Number, like previous defaults.

Option
Description
Type
default

Previous options supportBigNumbers and bigNumberStrings still exist for compatibility, but are now deprecated.

Custom logging API

Driver permit mapping the logs to an external logger. There is 3 caller functions:

  • network(string): called for each network exchange.

  • query(string): called for each commands

  • error(Error): called for each error.

if setting one function, function will be used for all loggers. (ie. logger: console.log === logger: { network: console.log, query: console.log, error: console.log})

Example:

Changelog

For a complete list of changes made in this release, with links to detailed information on each push, see the .

insertIdAsNumber

Whether the query should return last insert id from INSERT/UPDATE command as BigInt or Number. default return BigInt

boolean

false

decimalAsNumber

Whether the query should return decimal as Number. If enabled, this might return approximate values.

boolean

false

bigIntAsNumber

Whether the query should return BigInt data type as Number. If enabled, this might return approximate values.

boolean

mariadb 10.6
connection.prepare(sql) → Promise
connection.execute(sql[, values]) → Promise
mariadb 10.6
Number
changelog

false

const prepare = await conn.prepare('INSERT INTO mytable(id,val) VALUES (?,?)');
await prepare.execute([1, 'val1']);
prepare.close();
await conn.execute('INSERT INTO mytable(id,val) VALUES (?,?)', [1, 'val1']);
const mariadb = require('mariadb');
const winston = require('winston');

const logger = winston.createLogger({
  level: 'info',
  transports: [
    // - Write all logs with level `error` and below to `error.log`
    // - Write all logs with level `info` and below to `combined.log`
    new winston.transports.Console({ filename: 'error.log', level: 'error' }),
    new winston.transports.Console({ filename: 'combined.log' })
  ]
});

const pool = mariadb.createPool({
  host: 'mydb.com',
  user:'myUser',
  password: 'myPwd',
  logger: {
    network: (msg) => logger.silly(msg),
    query: (msg) => logger.info(msg),
    error: (err) => logger.error(err),
  }
});

The most recent release of is:

Connector/Node.js 3.4.5 Download Now

Connector/Node.js Overview
About MariaDB Connector/Node.js
MariaDB Connector/Node.js
BIGINT
DECIMAL
BigInt

This page is: Copyright © 2025 MariaDB. All rights reserved.