New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-where-filter

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-where-filter

通过字符串生成查询条件语句

Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
6
20%
Maintainers
1
Weekly downloads
 
Created
Source

通过字符串生成查询条件语句

安装

npm install node-where-filter

示例

const wherefilter = require( 'node-where-filter' );

var exprTree = wherefilter.makeTree( 'name=Jack && age>10 && alias<10', { alias: 'other name' } );
console.log( exprTree );
// echo: [ '&&', [ '=', 'name', 'Jack' ], [ '>', 'age', 10 ] ]

var dataTable = [
	{ name: 'Jack', age: 20 },
	{ name: 'Jack', age: 29 },
	{ name: 'Mike', age: 20 },
	{ name: 'Jack', age: 9 },
];
console.log( dataTable.filter( wherefilter.where( exprTree ) ) );
// echo: [ { name: 'Jack', age: 20 }, { name: 'Jack', age: 29 } ]

console.log( wherefilter.whereSQL( exprTree ) );
// echo: ( `name` = "Jack" ) AND ( `age` > 10 )

特别说明

字符串: "aaa\"bbb"

支持的操作符:
比较操作符: ~(regexp) !~(regexp) = != < > <= >=
规则: key operator value

逻辑操作符: && ||
规则: expr operator expr

Keywords

array

FAQs

Package last updated on 11 May 2017

Did you know?

Socket

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.

Install

Related posts