Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
criterion can describe sql where-conditions as objects for nodejs
inspired by the mongo query language
npm install criterion
criterion = require 'criterion'
c = criterion 'x = ?', 6
c.sql() # 'x = ?'
c.params() # [6]
c = criterion {x: 7}
c.sql() # 'x = ?'
c.params() # [7]
and
and or
fst = criterion {x: 7, y: 'foo'}
snd = criterion 'z = ?', true
fst.and(snd).sql() # '(x = ?) AND (y = ?) AND (z = ?)'
fst.and(snd).params() # [7, 'foo', true]
snd.or(fst).sql() # '(z = ?) OR (x = ? AND y = ?)'
snd.or(fst).params() # [true, 7, 'foo']
not
c = criterion {x: 7, y: 'foo'}
c.not().sql() # 'NOT ((x = ?) AND (y = ?))'
c.not().params() # [7, 'foo', true]
c.not().not().sql() # '(x = ?) AND (y = ?)'
c.not().not().params() # [7, 'foo', true]
criteria are immutable: and
, or
and not
return new objects.
criterion
x = 7
and y = 'foo'
{x: 7, y: 'foo'}
# or
[{x: 7}, {y: 'foo'}]
# or
'x = ? AND y = ?', 7, 'foo'
x
is in [1, 2, 3]
{x: [1, 2, 3]}
x
is not in [1, 2, 3]
{x: {$nin: [1, 2, 3]}}
x != 3
{x: {$ne: 3}}
# or
'x != ?', 3
x < 3
and y <= 4
{x: {$lt: 3}, y: {$lte: 4}}
# or
'x < ? AND y <= ?', 3, 4
x > 3
and y >= 4
{x: {$gt: 3}, y: {$gte: 4}}
# or
'x > ? AND y >= ?', 3, 4
x > 3
and y >= 4
){$not: {x: {$gt: 3}, y: {$gte: 4}}}
# or
'NOT (x > ? AND y >= ?)', 3, 4
x < NOW()
'x < NOW()'
x
is between 5
and 10
'x BETWEEN ? AND ?', 5, 10
x = 7
or y = 6
{$or: [{x: 7}, {y: 6}]}
# or
{$or: {x: 7, y: 6}}
# or
'x = ? OR y = ?', 7, 6
x
is null
{x: {$null: true}}
# or
'x IS NULL'
x
is not null
{x: {$null: false}}
# or
'x IS NOT NULL'
all query parts can be composed at will!
FAQs
criterion allows you to work with (build, combine, reuse, ...) SQL-where-conditions ('x = 5 AND y IS NOT NULL'...) as data (goodbye string-concatenation) and compile them to SQL: it has a succinct mongodb-like query-language, a simple and elegant function
The npm package criterion receives a total of 23 weekly downloads. As such, criterion popularity was classified as not popular.
We found that criterion 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.