node-query/lib/drivers/Mysql.js

32 lines
722 B
JavaScript
Raw Permalink Normal View History

/**
* Driver for MySQL databases
*
* @module drivers/Mysql
*/
module.exports = (() => {
delete require.cache[require.resolve('../Driver')];
const driver = require('../Driver');
const Helpers = require('../Helpers');
driver.identifierStartChar = '`';
driver.identifierEndChar = '`';
/**
2015-12-07 15:58:31 -05:00
* Set the limit clause
*
2015-12-07 15:58:31 -05:00
* @param {String} sql - SQL statement to modify
* @param {Number} limit - Maximum number of rows to fetch
* @param {Number|null} offset - Number of rows to skip
* @return {String} - Modified SQL statement
*/
driver.limit = (sql, limit, offset) => {
sql += (Helpers.isNumber(offset))
? ` LIMIT ${offset},${limit}`
: ` LIMIT ${limit}`;
return sql;
};
return driver;
})();