Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
简单的SQL语句构建工具。 A simple SQL query builder.
内置简单模型,支持MySQL的联合主键。
$ npm install sqlie --save
A base SELECT:
const {SelectBuilder} = require('sqlite');
const builder = new SelectBuilder()
.from('users')
.select('name,age,address')
.where('name', '=', 'Jon Snow')
.where('age', '=', 22);
builder.build();
// => SELECT `name`, `age`, `address` FROM `users` WHERE `name` = 'Swat' AND `age` = 22
SELECT with a simple JOIN:
const {SelectBuilder} = require('sqlie');
const builder = new SelectBuilder()
.from('users', 'u') // alias 'u' for table 'users'
.select('*') // optional with select all
.where('name', '=', 'Jon Snow')
.where('age', '=', 22)
.join('hobbies', function(hobbyBuilder) {
hobbyBuilder
.setAlias('h')
.select('hobby') // select 'hobby' from table 'hobbies'
.onColumn('h.id', 'u.id');
})
.join('colors', function(colorBuilder) {
colorBuilder
.setAlias('c')
.select('favorite') // select 'favorite' from table 'colors'
.onColumn('c.user_id', 'u.id');
});
builder.build();
// => SELECT `u`.*, `h`.`hobby`, `c`.favorite FROM `users`
// JOIN `hobbies` ON `h`.`id` = `u`.`id`
// JOIN `colors` ON `c`.`user_id` = `u`.`id`
// WHERE `u`.`name` = 'Jon Snow' AND `u`.`age` = 22
INSERT
const {InsertBuilder} = require('./dist');
const builder = new InsertBuilder()
.into('users')
.set('name', 'Super Girl')
.setSome({
age: 18,
gender: 'female'
});
builder.build();
// => INSERT INTO `users` (`name`, `age`, `gender`) VALUES ('Super Girl', 18, 'female')
UPDATE
const {UpdateBuilder} = require('./dist');
const builder = new UpdateBuilder()
.from('users')
.set('age', 22)
.setSome({})
.where('name', '=', 'Super Girl');
builder.build();
// => UPDATE `users` SET `age` = 22 WHERE `name` = 'Super Girl'
设置SQL执行函数
const {createConnection} = require('mysql')
const {setQueryHandler, execute} = require('sqlie')
const connection = createConnection({/*db config*/});
// 设置 MySQL 语句执行函数
setQueryHandler(connection.query.bind(connection));
// 下面可以调用 execute 函数执行 SQL 语句了
execute('SELECT * FROM tableName').then(function ({rows, fields}) {
console.log(rows); // 查询结果
console.log(fields);// 相关字段信息(不一定有结果)
})
模型
const {createModel} = require('sqlie');
const user = createModel('my_users', 'uid');
// 联合主键 'gid'、'uid'
const msg = createModel('im_group_msgs', ['gid', 'uid']);
MIT © Frge frge@mail.com
FAQs
A simple Query builder working with NodeJS.
The npm package sqlie receives a total of 16 weekly downloads. As such, sqlie popularity was classified as not popular.
We found that sqlie 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.