
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
SQL generator for node.js modeled after Zend_Db_Select. Intended for use with easy-mysql
The query generation is separated into two parts: query and params. You can
access the string query and params array for all objects using
Query.toString()
and Query.params()
The Query.all()
function returns an array of the query and parameters, and
optionally a callback. Typically you would use easy-mysql like so:
zsql.select(easyMySQL)
.from('tableName')
.where('columnName', 'value')
.limit(100)
.getAll(function(err, results) {
if( err ) throw err;
doSomething(results);
});
The getAll/getOne/execute functions are just proxies for easy-mysql:
this._mysql.execute.apply(this._mysql, this.all(callback));
Below is provided various examples and the resultant SQL and parameters that would be passed into easy-mysql.
zsql.select()
.from('tableName')
.where('columnName', 1)
.where('columnName2 > ?', 2)
.whereIn('columnName3', [3, 4])
.order('columnName4', 'ASC')
.limit(5)
.offset(20)
.all();
[ 'SELECT * FROM `tableName` WHERE `columnName` = ? && columnName2 > ? && `columnName3` IN (?, ?) ORDER BY `columnName4` ASC LIMIT ?, ?',
[ 1,
2,
3,
4,
20,
5 ] ]
zsql.insert()
.into('tableName')
.value('columnName', 1)
.value('columnName2', zsql.expr('NOW()'))
.all();
[ 'INSERT INTO `tableName` (`columnName`, `columnName2`) VALUES (?, NOW())',
[ 1 ] ]
zsql.del()
.from('tableName')
.where('columnName', 112358)
.limit(1)
.all();
[ 'DELETE FROM `tableName` WHERE `columnName` = ? LIMIT ?',
[ 112358, 1 ] ]
zsql.update()
.table('tableName')
.set('columnName1', 3.14)
.set('columnName2', zsql.expr('columnName2 + 1'))
.set('columnName3', 'value')
.where('columnName4', 159)
.limit(2)
.all();
[ 'UPDATE `tableName` SET `columnName1` = ? , `columnName2` = columnName2 + 1 , `columnName3` = ? WHERE `columnName4` = ? LIMIT ?',
[ 3.14, 'value', 159, 2 ] ]
FAQs
SQL generator modeled after Zend_Db_Select
The npm package zsql receives a total of 1 weekly downloads. As such, zsql popularity was classified as not popular.
We found that zsql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.