baja-lite 1.5.15 → 1.5.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/sql.d.ts +16 -0
- package/sql.js +80 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baja-lite",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.16",
|
|
4
4
|
"description": "some util for self",
|
|
5
5
|
"homepage": "https://github.com/void-soul/baja-lite",
|
|
6
6
|
"repository": {
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"@types/better-sqlite3": "7.6.13",
|
|
58
58
|
"@types/lodash.get": "4.4.9",
|
|
59
59
|
"@types/mustache": "4.2.6",
|
|
60
|
-
"@types/node": "24.0.
|
|
60
|
+
"@types/node": "24.0.12",
|
|
61
61
|
"@types/shelljs": "0.8.17",
|
|
62
62
|
"@types/sqlstring": "2.3.2",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
64
|
-
"@typescript-eslint/parser": "8.
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "8.36.0",
|
|
64
|
+
"@typescript-eslint/parser": "8.36.0",
|
|
65
65
|
"better-sqlite3": "12.2.0",
|
|
66
66
|
"ioredis": "5.6.1",
|
|
67
67
|
"mongodb": "6.17.0",
|
package/sql.d.ts
CHANGED
|
@@ -1641,6 +1641,10 @@ declare class StreamQuery<T extends object> {
|
|
|
1641
1641
|
isNULL(key: keyof T): this;
|
|
1642
1642
|
/** AND key IS NOT NULL */
|
|
1643
1643
|
isNotNULL(key: keyof T): this;
|
|
1644
|
+
/** AND (key IS NULL OR key = '') */
|
|
1645
|
+
isEmpty(key: keyof T): this;
|
|
1646
|
+
/** AND key IS NOT NULL AND key <> ''*/
|
|
1647
|
+
isNotEmpty(key: keyof T): this;
|
|
1644
1648
|
/** AND key BETWEEN :value1 AND :value2 */
|
|
1645
1649
|
between(key: keyof T, value1: string | number, value2: string | number, { paramName, skipEmptyString, breakExcuteIfEmpty }?: {
|
|
1646
1650
|
paramName?: string | undefined;
|
|
@@ -1721,6 +1725,18 @@ declare class StreamQuery<T extends object> {
|
|
|
1721
1725
|
skipEmptyString?: boolean | undefined;
|
|
1722
1726
|
breakExcuteIfEmpty?: boolean | undefined;
|
|
1723
1727
|
}): this;
|
|
1728
|
+
/** AND FIND_IN_SET(:value, key) */
|
|
1729
|
+
findInSet(key: keyof T, value: string | number, { paramName, skipEmptyString, breakExcuteIfEmpty }?: {
|
|
1730
|
+
paramName?: string | undefined;
|
|
1731
|
+
skipEmptyString?: boolean | undefined;
|
|
1732
|
+
breakExcuteIfEmpty?: boolean | undefined;
|
|
1733
|
+
}): this;
|
|
1734
|
+
/** AND FIND_IN_SET(key, :value) */
|
|
1735
|
+
findInSet2(key: keyof T, value: string | number, { paramName, skipEmptyString, breakExcuteIfEmpty }?: {
|
|
1736
|
+
paramName?: string | undefined;
|
|
1737
|
+
skipEmptyString?: boolean | undefined;
|
|
1738
|
+
breakExcuteIfEmpty?: boolean | undefined;
|
|
1739
|
+
}): this;
|
|
1724
1740
|
and(fn: StreamQuery<T> | ((stream: StreamQuery<T>) => boolean | void)): this;
|
|
1725
1741
|
or(fn: StreamQuery<T> | ((stream: StreamQuery<T>) => boolean | void)): this;
|
|
1726
1742
|
/** SET key = IFNULL(key, 0) + :value */
|
package/sql.js
CHANGED
|
@@ -3601,6 +3601,16 @@ class StreamQuery {
|
|
|
3601
3601
|
isNULL(key) { return this._null(key); }
|
|
3602
3602
|
/** AND key IS NOT NULL */
|
|
3603
3603
|
isNotNULL(key) { return this._null(key, 'NOT'); }
|
|
3604
|
+
/** AND (key IS NULL OR key = '') */
|
|
3605
|
+
isEmpty(key) {
|
|
3606
|
+
this._wheres.push(`AND (${this[_fields][String(key)]?.C2()} IS NULL OR ${this[_fields][String(key)]?.C2()} = '')`);
|
|
3607
|
+
return this;
|
|
3608
|
+
}
|
|
3609
|
+
/** AND key IS NOT NULL AND key <> ''*/
|
|
3610
|
+
isNotEmpty(key) {
|
|
3611
|
+
this._wheres.push(`AND ${this[_fields][String(key)]?.C2()} IS NOT NULL AND ${this[_fields][String(key)]?.C2()} <> ''`);
|
|
3612
|
+
return this;
|
|
3613
|
+
}
|
|
3604
3614
|
/** AND key BETWEEN :value1 AND :value2 */
|
|
3605
3615
|
between(key, value1, value2, { paramName = '', skipEmptyString = true, breakExcuteIfEmpty = true } = {}) { return this._between(key, value1, value2, { paramName, skipEmptyString, breakExcuteIfEmpty }); }
|
|
3606
3616
|
/** AND key NOT BETWEEN :value1 AND :value2 */
|
|
@@ -3629,6 +3639,52 @@ class StreamQuery {
|
|
|
3629
3639
|
includes(key, value, { paramName = '', skipEmptyString = true, breakExcuteIfEmpty = true } = {}) { return this._includes(key, value, { paramName, skipEmptyString, breakExcuteIfEmpty }); }
|
|
3630
3640
|
/** AND NOT LOCATE(key, :value) = 0 */
|
|
3631
3641
|
notIncludes(key, value, { paramName = '', skipEmptyString = true, breakExcuteIfEmpty = true } = {}) { return this._includes(key, value, { paramName, skipEmptyString, not: 'NOT', breakExcuteIfEmpty }); }
|
|
3642
|
+
/** AND FIND_IN_SET(:value, key) */
|
|
3643
|
+
findInSet(key, value, { paramName = '', skipEmptyString = true, breakExcuteIfEmpty = true } = {}) {
|
|
3644
|
+
if (value === null
|
|
3645
|
+
|| value === undefined
|
|
3646
|
+
|| (emptyString(`${value ?? ''}`) && skipEmptyString)) {
|
|
3647
|
+
if (breakExcuteIfEmpty) {
|
|
3648
|
+
this.if_exec = false;
|
|
3649
|
+
}
|
|
3650
|
+
return this;
|
|
3651
|
+
}
|
|
3652
|
+
if (paramName !== undefined && this._paramKeys.hasOwnProperty(paramName)) {
|
|
3653
|
+
this._param[this._paramKeys[paramName]] = value;
|
|
3654
|
+
}
|
|
3655
|
+
else {
|
|
3656
|
+
const pkey = `p${this._prefix}${this._index++}`;
|
|
3657
|
+
this._wheres.push(`AND FIND_IN_SET(:${pkey}, ${this[_fields][String(key)]?.C2()})`);
|
|
3658
|
+
this._param[pkey] = value;
|
|
3659
|
+
if (paramName) {
|
|
3660
|
+
this._paramKeys[paramName] = pkey;
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
return this;
|
|
3664
|
+
}
|
|
3665
|
+
/** AND FIND_IN_SET(key, :value) */
|
|
3666
|
+
findInSet2(key, value, { paramName = '', skipEmptyString = true, breakExcuteIfEmpty = true } = {}) {
|
|
3667
|
+
if (value === null
|
|
3668
|
+
|| value === undefined
|
|
3669
|
+
|| (emptyString(`${value ?? ''}`) && skipEmptyString)) {
|
|
3670
|
+
if (breakExcuteIfEmpty) {
|
|
3671
|
+
this.if_exec = false;
|
|
3672
|
+
}
|
|
3673
|
+
return this;
|
|
3674
|
+
}
|
|
3675
|
+
if (paramName !== undefined && this._paramKeys.hasOwnProperty(paramName)) {
|
|
3676
|
+
this._param[this._paramKeys[paramName]] = value;
|
|
3677
|
+
}
|
|
3678
|
+
else {
|
|
3679
|
+
const pkey = `p${this._prefix}${this._index++}`;
|
|
3680
|
+
this._wheres.push(`AND FIND_IN_SET(${this[_fields][String(key)]?.C2()}, :${pkey})`);
|
|
3681
|
+
this._param[pkey] = value;
|
|
3682
|
+
if (paramName) {
|
|
3683
|
+
this._paramKeys[paramName] = pkey;
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
return this;
|
|
3687
|
+
}
|
|
3632
3688
|
and(fn) {
|
|
3633
3689
|
if (fn instanceof StreamQuery) {
|
|
3634
3690
|
this._andQuerys.push(fn);
|
|
@@ -4393,6 +4449,18 @@ __decorate([
|
|
|
4393
4449
|
__metadata("design:paramtypes", [Object]),
|
|
4394
4450
|
__metadata("design:returntype", void 0)
|
|
4395
4451
|
], StreamQuery.prototype, "isNotNULL", null);
|
|
4452
|
+
__decorate([
|
|
4453
|
+
IF_PROCEED(),
|
|
4454
|
+
__metadata("design:type", Function),
|
|
4455
|
+
__metadata("design:paramtypes", [Object]),
|
|
4456
|
+
__metadata("design:returntype", void 0)
|
|
4457
|
+
], StreamQuery.prototype, "isEmpty", null);
|
|
4458
|
+
__decorate([
|
|
4459
|
+
IF_PROCEED(),
|
|
4460
|
+
__metadata("design:type", Function),
|
|
4461
|
+
__metadata("design:paramtypes", [Object]),
|
|
4462
|
+
__metadata("design:returntype", void 0)
|
|
4463
|
+
], StreamQuery.prototype, "isNotEmpty", null);
|
|
4396
4464
|
__decorate([
|
|
4397
4465
|
IF_PROCEED(),
|
|
4398
4466
|
__metadata("design:type", Function),
|
|
@@ -4477,6 +4545,18 @@ __decorate([
|
|
|
4477
4545
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
4478
4546
|
__metadata("design:returntype", void 0)
|
|
4479
4547
|
], StreamQuery.prototype, "notIncludes", null);
|
|
4548
|
+
__decorate([
|
|
4549
|
+
IF_PROCEED(),
|
|
4550
|
+
__metadata("design:type", Function),
|
|
4551
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
4552
|
+
__metadata("design:returntype", void 0)
|
|
4553
|
+
], StreamQuery.prototype, "findInSet", null);
|
|
4554
|
+
__decorate([
|
|
4555
|
+
IF_PROCEED(),
|
|
4556
|
+
__metadata("design:type", Function),
|
|
4557
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
4558
|
+
__metadata("design:returntype", void 0)
|
|
4559
|
+
], StreamQuery.prototype, "findInSet2", null);
|
|
4480
4560
|
__decorate([
|
|
4481
4561
|
IF_PROCEED(),
|
|
4482
4562
|
__metadata("design:type", Function),
|