
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
# mysqls It is written in JavaScript. crud for mysql. You can also use transactions very easily.
It is written in JavaScript. crud for mysql. You can also use transactions very easily.
mysqls:A plug-in that generates SQL statements for node.js. call chaining .simple to use. support transaction.
npm install mysqls --save
or
yarn add mysqls
- init: sql Initialization
- exec: Executing SQL statements
- sql: Chain Call Generates SQL Statement
- transaction: transaction API
//import
import { init, exec, sql, transaction } from 'mysqls'
//require
let { init, exec, sql, transaction } = require('mysqls')
// You can initialize the configuration at project startup
init({
host: 'localhost',
user: 'root',
password:'123456',
database: 'test',
port: 3306,
})
- ispool: Is it initialized as a connection pool. (default:true)
- host: host address. (default:'127.0.0.1')
- user: user. (default:'root')
- password: password. (default:'root')
- database: database. (default:'test')
- port: port. (default:'3306')
- waitConnection: wait for connections. (default:true)
- connectionLimit: connection limit. (default:10)
- queueLimit: queue limit. (default:0)
sql
.table('node_table')
.field('id,name')
.where({id:1})
.select()
// result
SELECT id,name FROM node_table WHERE id=1
const sqlstr = sql
.table('node_table')
.field('id,name')
.where({id:1})
.select();
const result = await exec(sqlstr);
const result = sql
.table('node_table')
.field('id,name')
.where({id:1})
.select(true)
.exec();
// use exec function
exec(sql.table('web_pages').where({id:147}).select())
.then(res=>{
console.log(res)
}).catch(err=>{
console.log(err)
})
// use exec method
sql.table('web_pages').where({id:147}).select(true).exec()
.then(res=>{
console.log(res)
}).catch(err=>{
console.log(err)
})
// use exec function
const result = await exec(sql.table('web_pages').where({id:147}).select())
// use exec method
const result = await sql.table('web_pages').where({id:147}).select(true).exec()
const tranSqlArr = [
sql.table('table1').data({number:'number-5'}).update(true,true),
sql.table('table2').data({number:'number+5'}).update(true,true)
]
const result = await transaction(tranSqlArr)
select
sql
.table('node_table')
.field('id,name')
.where({id:1})
.select()
SELECT id,name FROM node_table WHERE id=1
insert
sql
.table('node_table')
.data({name:'zane',email:'752636052@qq.com'})
.insert()
INSERT INTO node_table (name,email) VALUES (`zane`,`752636052@qq.com`)
batch insert
let data = [
{name:'zane',email:'752636052@qq.com'},
{name:'zane_1',email:'752636052_1@qq.com'},
{name:'zane_2',email:'752636052_2@qq.com'},
]
sql
.table('node_table')
.data(data)
.insert()
INSERT INTO node_table (name,email) VALUES ('zane','752636052@qq.com'),('zane_1','752636052_1@qq.com'),('zane_2','752636052_2@qq.com')
update
sql
.table('node_table')
.data({name:'zane',email:'752636052@qq.com'})
.where({id:1})
.update()
UPDATE node_table SET name=`zane`,email=`752636052@qq.com`
delet
sql .table('node_table')
.where({name:'zane'})
.delet();
DELETE FROM node_table WHERE name=`zane`
// parameter json
sql
.table('node_table')
.where({id:1,name:'zane'})
.select()
SELECT * FROM node_table WHERE id=1 AND name=`zane`
// parameter array
let data=[
{id:1,name:'zhangsan',_type:'or'},
{sex:1,number:3}
]
sql.table('node_table').where(data).select()
SELECT * FROM node_table WHERE (id=1 OR name=`zhangsan` ) AND (sex=1 AND number=3 )
// multiple fields
let data=[
{id:1,name:'zhangsan',_type:'or',_nexttype:'or'},
{sex:1,number:3,_type:'and'}
]
sql.table('node_table').where(data).select()
SELECT * FROM node_table WHERE (id=1 OR name=`zhangsan`) OR (sex=1 AND number=3)
// Expression Query
let data={
id:{eq:100,egt:10,_type:'or'},
name:'zhangshan'
}
sql.table('node_table').where(data).select()
SELECT * FROM node_table WHERE ((id=100) OR (id>=10)) AND name=`zhangshan`
// Multiple queries
let data=[{
id:{eq:100,egt:10,_type:'or'},
name:'zhangshan',
_nexttype:'or'
},{
status:1,
name:{like:'%zane%'}
}]
sql.table('node_table').where(data).select()
SELECT * FROM node_table WHERE (((id=100) OR (id>=10)) AND name=`zhangshan`) OR (status=1 AND ((name LIKE `%zane%`)))
//UNION , UNION ALL
sql
.union('SELECT * FROM think_user_1',true)
.union('SELECT * FROM think_user_2',true)
.union(['SELECT * FROM think_user_3','SELECT name FROM think_user_4'])
.union('SELECT * FROM think_user_5',true)
.select()
result
(SELECT * FROM think_user_1) UNION ALL
(SELECT * FROM think_user_2) UNION ALL
(SELECT * FROM think_user_3) UNION
(SELECT name FROM think_user_4) UNION
(SELECT * FROM think_user_5)
FAQs
# mysqls It is written in JavaScript. crud for mysql. You can also use transactions very easily.
The npm package mysqls receives a total of 8 weekly downloads. As such, mysqls popularity was classified as not popular.
We found that mysqls 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
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket investigates hidden protestware in npm packages that blocks user interaction and plays the Ukrainian anthem for Russian-language visitors.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.