Socket
Socket
Sign inDemoInstall

sqrolls

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.5.0

15

dist/basebuilders.d.ts

@@ -84,2 +84,17 @@ import * as pr from './predicates';

whereIsNotNullIf(field: string, check: boolean): T;
/**
* Adds a check for a specific pattern for the given field.
*
* @param field The field name
* @param pattern The string pattern
*/
whereIsLike(field: string, pattern: string): T;
/**
* Adds a check for a specific pattern for the given field
*
* @param field The field name
* @param pattern The string pattern
* @param check The conditional check
*/
whereIsLikeIf(field: string, pattern: string, check: boolean): T;
}

31

dist/basebuilders.js

@@ -46,3 +46,3 @@ "use strict";

if (check) {
this.whereIsEqual(field, arg);
return this.whereIsEqual(field, arg);
}

@@ -69,3 +69,3 @@ return this.getThis();

if (check) {
this.whereIsNotEquals(field, arg);
return this.whereIsNotEquals(field, arg);
}

@@ -91,3 +91,3 @@ return this.getThis();

if (check) {
this.whereIsNull(field);
return this.whereIsNull(field);
}

@@ -113,7 +113,30 @@ return this.getThis();

if (check) {
this.whereIsNotNull(field);
return this.whereIsNotNull(field);
}
return this.getThis();
}
/**
* Adds a check for a specific pattern for the given field.
*
* @param field The field name
* @param pattern The string pattern
*/
whereIsLike(field, pattern) {
this.predicates.push(pr.isLike(field, pattern));
return this.getThis();
}
/**
* Adds a check for a specific pattern for the given field
*
* @param field The field name
* @param pattern The string pattern
* @param check The conditional check
*/
whereIsLikeIf(field, pattern, check) {
if (check) {
return this.whereIsLike(field, pattern);
}
return this.getThis();
}
}
exports.PredicateBaseBuilder = PredicateBaseBuilder;

@@ -35,3 +35,3 @@ /**

/**
* `<field> IS NOT NULL` check between a field and the given arg.
* `<field> IS NOT NULL` check between a field and the given arg.
*

@@ -42,1 +42,8 @@ * @param field The field name

export declare function isNotNull(field: string): Predicate;
/**
* `<field> is LIKE <arg>` check between a field and the string pattern
*
* @param field The field name
* @param pattern The user given pattern
*/
export declare function isLike(field: string, pattern: string): Predicate;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNotNull = exports.isNull = exports.isNotEqual = exports.isEqual = exports.Predicate = void 0;
exports.isLike = exports.isNotNull = exports.isNull = exports.isNotEqual = exports.isEqual = exports.Predicate = void 0;
/**

@@ -51,3 +51,3 @@ * Defines a sql predicate statement used to narrow queries.

/**
* `<field> IS NOT NULL` check between a field and the given arg.
* `<field> IS NOT NULL` check between a field and the given arg.
*

@@ -61,1 +61,11 @@ * @param field The field name

exports.isNotNull = isNotNull;
/**
* `<field> is LIKE <arg>` check between a field and the string pattern
*
* @param field The field name
* @param pattern The user given pattern
*/
function isLike(field, pattern) {
return new Predicate(`${field} LIKE ?`, pattern);
}
exports.isLike = isLike;

2

package.json
{
"name": "sqrolls",
"version": "0.4.0",
"version": "0.5.0",
"description": "sql builder library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -59,2 +59,16 @@ # sqrolls

Selecting all users with names that start with "Frank".
```js
const qb = Select.builder()
.select('*')
.from('users')
.whereIsLike('name', 'Frank%')
const [ stmt, args ] = qb.toSQL();
// stmt: 'SELECT * FROM users WHERE name LIKE ?'
// args: ['Frank%']
```
We sometimes need to query a table based on a search filter with optional fields.

@@ -61,0 +75,0 @@ The conditional where methods can help with this. Searching for archived users if

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc