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
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.
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.
Previous options supportBigNumbers and bigNumberStrings still exist for compatibility, but are now deprecated.
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:
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
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),
}
});This page is: Copyright © 2025 MariaDB. All rights reserved.