Socket
Socket
Sign inDemoInstall

sqrolls

Package Overview
Dependencies
102
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.2 to 0.6.1

7

dist/basebuilders.d.ts

@@ -99,2 +99,9 @@ import * as pr from './predicates';

whereIsLikeIf(field: string, pattern: string, check: boolean): T;
/**
* Adds a set membership check
*
* @param field The field name
* @param args The value list
*/
whereIn(field: string, ...args: unknown[]): T;
}

@@ -137,3 +137,13 @@ "use strict";

}
/**
* Adds a set membership check
*
* @param field The field name
* @param args The value list
*/
whereIn(field, ...args) {
this.predicates.push(pr.isIn(field, args));
return this.getThis();
}
}
exports.PredicateBaseBuilder = PredicateBaseBuilder;

8

dist/insert.js

@@ -8,6 +8,2 @@ "use strict";

class Insert extends basebuilders_1.BaseBuilder {
constructor() {
super();
this.values = [];
}
static builder() {

@@ -19,2 +15,6 @@ return new Insert();

}
constructor() {
super();
this.values = [];
}
/**

@@ -21,0 +21,0 @@ * @param table The table to insert into

@@ -42,3 +42,3 @@ /**

/**
* `<field> is LIKE <arg>` check between a field and the string pattern
* `<field> LIKE <arg>` check between a field and the string pattern
*

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

export declare function isLike(field: string, pattern: string): Predicate;
/**
* `<field> IN (<args>)` check between a field and the given args
*
* @param field The field name
* @param args The set values
*/
export declare function isIn(field: string, args: unknown[]): Predicate;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLike = exports.isNotNull = exports.isNull = exports.isNotEqual = exports.isEqual = exports.Predicate = void 0;
exports.isIn = exports.isLike = exports.isNotNull = exports.isNull = exports.isNotEqual = exports.isEqual = exports.Predicate = void 0;
/**

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

/**
* `<field> is LIKE <arg>` check between a field and the string pattern
* `<field> LIKE <arg>` check between a field and the string pattern
*

@@ -71,1 +71,12 @@ * @param field The field name

exports.isLike = isLike;
/**
* `<field> IN (<args>)` check between a field and the given args
*
* @param field The field name
* @param args The set values
*/
function isIn(field, args) {
const wildcards = args.map(() => '?').join(',');
return new Predicate(`${field} IN (${wildcards})`, args);
}
exports.isIn = isIn;

@@ -31,25 +31,25 @@ import { PredicateBaseBuilder } from './basebuilders';

*
* @param val The result set limit
* @param limit The result set limit
*/
limit(val: number): Select;
limit(limit: number): Select;
/**
* Sets an offset on the select query
*
* @param val The result set offset
* @param offset The result set offset
*/
offset(val: number): Select;
offset(offset: number): Select;
/**
* Sets a limit on the select query if predicate is true
*
* @param val The result set limit
* @param limit The result set limit
* @param check The conditional check
*/
limitIf(val: number, check: boolean): Select;
limitIf(limit: number | undefined, check: boolean): Select;
/**
* Sets an offset on the select query
*
* @param val The result set offset
* @param offset The result set offset
* @param check The conditional check
*/
offsetIf(val: number, check: boolean): Select;
offsetIf(offset: number | undefined, check: boolean): Select;
/**

@@ -56,0 +56,0 @@ * Builds the final select statement.

@@ -44,6 +44,6 @@ "use strict";

*
* @param val The result set limit
* @param limit The result set limit
*/
limit(val) {
this._limit = val;
limit(limit) {
this._limit = limit;
return this;

@@ -54,6 +54,6 @@ }

*
* @param val The result set offset
* @param offset The result set offset
*/
offset(val) {
this._offset = val;
offset(offset) {
this._offset = offset;
return this;

@@ -64,8 +64,8 @@ }

*
* @param val The result set limit
* @param limit The result set limit
* @param check The conditional check
*/
limitIf(val, check) {
if (check) {
this.limit(val);
limitIf(limit, check) {
if (limit !== undefined && check) {
this.limit(limit);
}

@@ -77,8 +77,8 @@ return this;

*
* @param val The result set offset
* @param offset The result set offset
* @param check The conditional check
*/
offsetIf(val, check) {
if (check) {
this.offset(val);
offsetIf(offset, check) {
if (offset !== undefined && check) {
this.offset(offset);
}

@@ -95,3 +95,5 @@ return this;

stmt += ' WHERE ' + this.predicates.map(p => p.clause).join(' AND ');
const _args = this.predicates.filter(p => p.hasArg()).map(p => p.arg);
const _args = this.predicates
.filter(p => p.hasArg())
.flatMap(p => p.arg);
args.push(..._args);

@@ -98,0 +100,0 @@ }

@@ -8,2 +8,5 @@ "use strict";

class Update extends basebuilders_1.PredicateBaseBuilder {
static builder() {
return new Update();
}
constructor() {

@@ -13,5 +16,2 @@ super();

}
static builder() {
return new Update();
}
getThis() {

@@ -18,0 +18,0 @@ return this;

{
"name": "sqrolls",
"version": "0.5.2",
"description": "sql builder library",
"keywords": [
"sqlite3",
"mysql",
"query builder"
],
"main": "./dist/index.js",
"repository": {
"type": "git",
"url": "https://github.com/sugatpoudel/sqrolls.git"
},
"author": "tagus",
"license": "MIT",
"files": [
"dist/**/*"
],
"scripts": {
"build": "tsc",
"test": "jest",
"prepublishOnly": "yarn test",
"prepare": "yarn build"
},
"dependencies": {},
"devDependencies": {
"@types/jest": "^26.0.9",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"jest": "^26.2.2",
"ts-jest": "^26.1.4",
"typescript": "^3.9.7"
}
"name": "sqrolls",
"version": "0.6.1",
"description": "sql builder library",
"keywords": [
"sqlite3",
"mysql",
"query builder"
],
"main": "./dist/index.js",
"repository": {
"type": "git",
"url": "https://github.com/sugatpoudel/sqrolls.git"
},
"author": "tagus",
"license": "MIT",
"files": [
"dist/**/*"
],
"scripts": {
"build": "tsc",
"test": "jest",
"prepublishOnly": "yarn test",
"prepare": "yarn build"
},
"dependencies": {
"eslint": "^8.48.0"
},
"devDependencies": {
"@types/jest": "^29.5.4",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"jest": "^29.6.4",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
}
}

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

Selecting all users with ids in the given list.
```js
const qb = Select.builder()
.select('*')
.from('users')
.whereIn('id', 1, 2, 3, 4)
const [ stmt, args ] = qb.toSQL();
// stmt: 'SELECT * FROM users WHERE id IN (?,?,?,?)'
// args: [1, 2, 3, 4]
```
### inserts

@@ -95,0 +109,0 @@

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